Python基本循环实例Day 1
程序员文章站
2024-03-30 21:44:57
输入正确的用户名和密码,显示登陆界面,超过三次输入错误则锁定,定义字符串记得加上单引号,数字可以int定义,while循环和if循环语句后加上:,break不加: ......
输入正确的用户名和密码,显示登陆界面,超过三次输入错误则锁定,定义字符串记得加上单引号,数字可以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.")
上一篇: 三种智能指针的使用与区别
下一篇: 有趣的python小程序分享