Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- count = 0
- counttimes = 0
- while counttimes < 3 : # 输入错误信息3次就锁定(终止循环)
- user = input('Please input your name: ')
- pwd = input('Please input your password: ')
- if user == 'liuchao' and pwd == '123456':
- print ('welcome to beijing')
- break #输入正确的用户名和密码显示欢迎信息并结束
- counttimes +=1 #counttimes = counttimes + 1 (输入错误时计数加1)
- else :
- counttimes +=1 #counttimes = counttimes + 1 (输入错误时计数加1)
- if count < 2 : #第三次输入错误后打印锁定提示不再显示再出输入
- count += 1
- print ('please enter again')
- else :
- print ('You are not allowed to enter !!!') #锁定提示
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement