Last active
October 5, 2016 05:23
-
-
Save Lvl4Sword/b1487d45627bf85e9c9357c318d835e2 to your computer and use it in GitHub Desktop.
Generate 16 random characters, with each 4 separated by a dash
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 random | |
import string | |
characters = string.digits + string.ascii_letters | |
random_selection = lambda: [random.choice(characters) for x in range(16)] | |
random_join = ''.join(random_selection()) | |
final_list = [] | |
counter = 1 | |
for each in random_join: | |
if counter % 4 == 0: | |
final_list.append(each) | |
final_list.append('-') | |
else: | |
final_list.append(each) | |
counter += 1 | |
print(''.join(final_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment