def account_login():
tries = 3
while tries > 0:
password = input('Password: ')
password_correct = password == password_list[-1]
password_reset = password == password_list[0]
if password_correct:
print('Login success!')
break
elif password_reset:
new_password = input('Enter a new password: ')
password_list.append(new_password)
print('Password has changed successfully!')
account_login()
else:
print('Wroing password or invalid input!')
tries = tries - 1
print(tries, 'time left')
else:
print('Your account has been suspended')
account_login()
如上代码,在修改密码后登陆,输入密码的时候需要输入两次才能跳出循环,没有明白哪里出了问题?
求大神赐教