python3 练习-登录

# Author:Mazhicheng
# Homework is login interface
# Date: 20171122

# requirement 1: input usrname and password
# requirement 2: if authentication success , welcome
# requirement 3: if input error three times ,lock

"""
step 1 : Have a username and a password
step 2 : Give a method to input the username and the password
step 3 : Judge the username and the password
if all right , output "welcome to the username !"
if the username or the password is error or all error , can try 2 times;
if the username or the password is error or all error again ,can try 1times;
if the username or the password is error or all error 3 times , lock and can't do anything;

"""

_username = "mazhicheng"
_password = "mzc"
_times = 3

while _times >= 1:

username = input("Input your name:")
password = input("Input your password:")

if username == _username and password == _password:
print("Welcome to you ,%s" % (_username))
break
elif _times == 1:
print("locked and can't do anything.")
else:
print("You input error , you can try %d times ." % (_times - 1))
_times -= 1

posted on 2017-11-22 21:29  苦僧  阅读(151)  评论(0)    收藏  举报

导航