Skip to content

Instantly share code, notes, and snippets.

@makmac213
Forked from markmeriales/gist:4058523
Last active December 11, 2015 22:48
Show Gist options
  • Save makmac213/4671646 to your computer and use it in GitHub Desktop.
Save makmac213/4671646 to your computer and use it in GitHub Desktop.
Return a random hex code
import random
def get_random_hex_by_length(length=4):
"""Returns a random hex code according to length"""
return hex(random.randint((16**((length)-1)),(16**length)))[2:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment