输入正确的用户名和密码,显示登陆界面,超过三次输入错误则锁定,定义字符串记得加上单引号,数字可以int定义,while循环和if循环语句后加上:,break不加:
print("---------Welcome to Memory Card Hotel!-------")
_username = 'wryyy'
_password = 123
count = 0
while count <3:
username = input("username:")
password = int(input("password:"))
if _username == username and _password == password:
print("Logining now...Welcome {name}!".format(name = _username))
break
else:
print("Invalid username or password.")
count = count +1
else:
print("LOCKED ON,you have tried too many times.")
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有