elif loginChoice=="Doctor" or loginChoice=="doctor":
inputPass=str(input("Input doctor's password:(see line 1 of code) "))
while True:
if inputPass != adminPass:
for tries in range (0,2):
print("Wrong password! Only "+str(2-tries)+" tries left.")
inputPass=str(input("Input doctor's password:(see line 1 of code) "))
if inputPass==adminPass:
break;
if tries==2:
break;
break;
else:
print("Permission granted...")
print(" ")
因此,我正在创建一种自我诊断程序,用于自我改进,并创建了一种医生登录方法,以便用户可以访问阵列中的数据。因此,我通过3次登录尝试向该登录添加了密码。然而,我意识到,如果我一次输入错误的密码,它会执行包含“仅错误尝试”循环的if循环,即使我第二次输入正确的密码,它也不会退出该循环并将我放入“else:”函数。有什么办法可以解决这个问题吗
让它更像这样怎么样:
不要让它变得如此复杂和混乱,只需创建一个变量,该变量可以跟踪用户的尝试,如果用户尝试次数为4次,则循环将自动停止尝试以下操作:
相关问题 更多 >
编程相关推荐