here I have some code I've been working on (Python 3.4) and I cant figure out on how to get the program to restart after the else statement I know theres no goto statement
I have tried messing about by putting the if statement in a while true loop but it just looped the print line and printed the output over and over again
import random
import string
PassGen = ""
length = int(input("how many characters would you like your password to have 8-15? "))
if 8 <= length <=15:
while len(PassGen) != length:
Num1 = random.choice(string.ascii_uppercase)
Num2 = random.choice(string.ascii_lowercase)
Num3 = random.choice(string.digits)
everything = [Num1, Num2, Num3]
PassGen += random.choice(everything)
print (PassGen)
else:
print ("that is an incorrect value")
at the moment it works perfectly fine by taking an input from the user then seeing if the input is between 8-15 if true then make a password with the furthest indented code if false then print incorrect value
Aucun commentaire:
Enregistrer un commentaire