I am fairly new to python, and I have a random password generator where the user types out the word 'generate' (my take on a button, if there is a better way please tell me) to get a new word. It generates a random word, joins it with a random number, then again a random word and then prints it. The issue is that I have just copied and pasted the code that runs each time, to be able to keep generating new passwords. What command can I use to loop this question?. Heres my code:
value = input("Type 'generate' to generate a new password.\n")
if value == 'generate':
line = open("words.txt").read()
line = line[0:]
words = line.split()
one = random.choice(words)
line = open("numbers.txt").read()
line = line[0:]
numbers = line.split()
two = random.choice(numbers)
line = open("words.txt").read()
line = line[0:]
words2 = line.split()
three = random.choice(words2)
print('Your new password is '+(one)+(two)+(three))