0
pss = input("Enter a password")
symb = ["!","£","$","%","^","&"]
num = ["1","2","3","4","5","6","7","8","9","0"]
done = 0#to break symbol check
done2 = 0#break num check
check = 0#keep track of things correct
found = False
while found == False:
#checks for a symbol in the password
for ch in pss:
done = done + 1
if ch in symb:
check = check + 1
break
elif done == len(pss):#done , only to say once
print("Add a symbol to your password")
#WORKS!! :D
#checks for number in password
for ch in pss:
done2 = done2 + 1
if ch in num:
check = check + 1
break
elif done2==len(pss):
print("Add a number to your password")
#capital letter check
if pss == pss.lower():
print("You need to have at least one capital letter")
else:
check = check + 1
#checking
if check == 3:
print("Password Validated")
found = True
else:
pss = input("Correct you password")#re enters password
check = 0
#need to make pss update correctly
它最後幾行我有麻煩,程序工作,只是密碼不更新,所以不必要的行被打印。例如,當輸入初始密碼「Jellybean」時,我會提醒您在密碼中添加一個數字和一個符號。接下來,當我得到oppununtiy糾正,我輸入「Jellybean5£」,我仍然被提示添加一個數字和一個符號。但是,由於密碼成功,程序會識別更改並退出。由於某種原因該變量不會更新?
你永遠不會重置'done'和'done2'變量。 –