我正在构建一个 ID Confirm 系统,用户有 3 次尝试输入 ID 正确,如果没有,系统将退出。我的问题是当用户最后一次输入正确的 ID 时,当代码正确时,语句写出 ID 是正确的,第二行显示他,他输入了太多的尝试和系统正在退出。我该如何修复这个错误?我该如何解决,当用户在 3/3 次尝试中输入正确的 ID 时,系统会说,正确,我们可以破坏 if 语句。我的代码:
checkas = True
Attempts = 3
CurrentAttemp = 0
KickForBadCode = sys.exit
while checkas:
CurrentAttemp += 1
IDConfirm = input("* [3NEMATIX]: {} Please confirm Your ID CODE... Attempt! {}/{} ".format(Vartotojo_Vardas, CurrentAttemp, Attempts))
with open (DuomenuBaz, mode = 'r', encoding = 'utf-8') as Confirm:
for line in Confirm:
if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():
print("Correct!")
Confirm.close()
checkas = False
break
elif "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip() and CurrentAttemp > 2:
clear()
print("Correct!")
Confirm.close()
checkas = False
break
elif CurrentAttemp >2:
clear()
print("~ You have been kicked for too many attempts!")
checkas = False
sys.exit
月关宝盒
慕尼黑5688855
相关分类