Created
October 7, 2015 05:29
-
-
Save guyoun/80ccde51006edb944fca to your computer and use it in GitHub Desktop.
To generate random sequence of letters and digits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
print string.ascii_letters | |
print string.digits | |
allow_letters = string.ascii_letters + string.digits | |
print allow_letters | |
random_string = [] | |
duplicated = 0 | |
for j in range(50000): | |
s = ''.join(random.choice(allow_letters) for i in range(3)) | |
if s not in random_string: | |
random_string.append(s) | |
else: | |
print 'duplicated' | |
duplicated = duplicated + 1 | |
print 'end' | |
print duplicated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment