博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

Python习题-登录

Posted on 2017-10-19 23:21  代码的味道是什么  阅读(178)  评论(0编辑  收藏  举报
写一个登录的程序,失败次数最多为3次,输入账号、密码错误,提示账号/密码错误。失败三次程序退出,输入正确,提示欢迎xxx登录
i=0
while (i<3):
username = input('请输入登录账号:')
password = input('请输入密码:')

if username=="niuniu" and password=="123":
print('hello,%s'%username)
break
else:
print('you are error,try again')
i=i+1
else:
print('you error over 3 times')