习题45、设定一个用户名和密码,用户输入正确的用户名和密码,则显示登录成功,否则提示登录失败,用户最多失败3次,否则退出程序。
方法1:
username="root"
password="123456"
for i in range(3):
user=input("please input the username:")
passwd=input("please input the passwd:")
if user==username and passwd == password:
print("guess ok")
break
else:
print("guess error")
if i==2:
print("input times is used out!bye!")
方法2:
username="root"
password="123456"
for i in range(3):
user=input("please input the username:")
passwd=input("please input the passwd:")
if user==username and pa