import random
import string
oneFile = open('password.txt', 'w')
userInput = 0
key_count = 0
key = []
chars = string.ascii_uppercase + string.digits + string.ascii_lowercase
for userInput in range(int(input('How many keys needed?'))):
while key_count <= userInput:
number = random.randint(1, 999)
if number not in key:
key_count += 1
key.append(number)
text = str(number) + ": " + str(''.join(random.sample(chars*6, 16)))
oneFile.write(text + "\n")
oneFile.close()
print("Data written, please Rename or it will be over written.")
raw_input("press enter to exit")
How do i get it so the out put looks like this:
955: PFtKg-r1fd1-g9FX23 with the dashes in-between after a chosen amount of characters?
text = str(number) + ": " + str(''.join(random.sample(chars*6, 16)))
#puts everything together but i would have to repeat
# + str(''.join(random.sample(chars*6, 16))) on the line in code