# Six ways to generate hex colors

```from string import hexdigits from random import randint colors_to_generate = 5 hexdigits = list(hexdigits) del hexdigits[10:16] for _ in range(colors_to_generate): print('#' + ''.join(hexdigits[randint(0, 15)] for _ in range(6)))from string import hexdigits from random import sample colors_to_generate = 5 hexdigits = list(hexdigits) del hexdigits[10:16] for _ in range(colors_to_generate): print('#' + ''.join(sample(hexdigits, 6))) from string import hexdigits from random import randint from operator import itemgetter colors_to_generate = 5 hexdigits = ''.join(set(hexdigits.upper())) for _ in range(colors_to_generate): indices = tuple([randint(0, 15) for _ in range(6)]) print('#' + ''.join(itemgetter(*indices) (hexdigits)))from string import hexdigits from random import shuffle colors_to_generate = 5 hexdigits = list(set(hexdigits.upper())) for _ in range(colors_to_generate): shuffle(hexdigits) print("#%s" % (''.join(hexdigits[-6:]))) from random import randint colors_to_generate = 5 for _ in range(colors_to_generate): r, g, b = randint(0,255), randint(0,255), randint(0,255) print("#{:02X}{:02X}{:02X}".format(r, g, b)) from random import randint colors_to_generate = 5 hexdigits = '0123456789ABCDEF' print('\n'.join(['#' + ''.join([hexdigits[randint(0, 15)] for _ in range(6)]) for _ in range(colors_to_generate)]))```