【发布时间】:2014-11-21 14:11:45
【问题描述】:
在程序中,用户必须输入密码,如果输入错误,程序将再提示他 2 次,如果输入错误,则该程序将过期。我该怎么做。到目前为止,这是我的程序...
password=input("Enter password:")
while password != 'cat':
print ("password is wrong, try it again")
password= input ("Enter your password:")
print ("Password correct be happy")
【问题讨论】:
-
把它放在一个循环中。如果收到正确的答案,则跳出循环。如果循环在没有正确答案的情况下到期,则执行其他操作。
标签: python python-3.x input passwords prompt