if userInput != userPassword:
print("I'm sorry, that is wrong please try again. Try to remember capitals!")
elif userInput == userPassword:
print("That is correct you may now find out your mobile phone costs!")
mobile_phone()
当它运行并且我输入错误的密码时,它只重复第一个打印声明(对不起,这是错误的,请再试一次。尝试记住大写字母!)我怎样才能让它再次运行一次ONCE如果它是错的,则可能是另一次,直到用正确的密码回答。首次亮相
答案 0 :(得分:3)
把它放在while循环中?
while (userInput != userPass) :
print ("wrong password")
// reask userPass
如果您想限制trys的数量,请举例说明3,只需添加一个计数器:
while (userInput != userPass && counter < 3) :
counter++
print ("wrong password")
// reask userPass