Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generates a random hexadecimal color (e.g. #ff0000)
def random_hexcolor():
color = '#'
while len(color) < 7:
hex = '{0:x}'.format(random.randrange(256))
if len(hex) < 2:
hex = '0' + hex
color += hex
return color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.