Skip to content

Instantly share code, notes, and snippets.

@Lvl4Sword
Last active October 5, 2016 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lvl4Sword/b1487d45627bf85e9c9357c318d835e2 to your computer and use it in GitHub Desktop.
Save Lvl4Sword/b1487d45627bf85e9c9357c318d835e2 to your computer and use it in GitHub Desktop.
Generate 16 random characters, with each 4 separated by a dash
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