Skip to content

Instantly share code, notes, and snippets.

@markmeriales
Created November 12, 2012 10:23
Show Gist options
  • Save markmeriales/4058523 to your computer and use it in GitHub Desktop.
Save markmeriales/4058523 to your computer and use it in GitHub Desktop.
get_random_hex_by_length
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:]
@markmeriales
Copy link
Author

Returns a random hex code according to length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment