if you run the code on python and then input anything that isnt a number for "please enter the password length: " then put in a number after that then the code wont run properly. i think this is because the pl variable has already been assigned to the character that wasnt a number but im not sure how to reset a variable
import random
def generator():
yessir = 0
pl = input("please enter the password length: ")
if pl.isnumeric():
pl=int(pl)
elif pl==str(pl):
print("thats not a number!")
generator()
if pl < 8:
poga=input("That password is a bit short. Would you like to continue? YES or NO: ")
if poga=="yes":
yessir = 1
elif poga == "no":
generator()
else:generator()
yessir = 1
if yessir == 1:
password = (random.choice("!QAZ@WSX#EDC$RFV%TGB^YHN&UJM*IK<(OL>)P:?_{'"))
while pl >= 1:
hacker = random.randint(1,4)
if hacker == 1: password = password+(random.choice("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
elif hacker == 2: password = password+(random.choice("abcdefghijklmnopqrstuvwxyz"))
elif hacker == 3: password = password+(random.choice("123456789"))
elif hacker == 4: password = password+(random.choice("!@#$%^&*(){}|_+:<>?~`,./;'[]\-="))
pl = pl - 1
if pl <= 1:print (password)
generator()