写代码:实现用户输入用户名和密码,当用户名为seven或者Alex且密码为123时,显示登录成功,否则失败,失败时允许重复输入三次。

#  实现用户输入用户名和密码,当用户名为seven或者Alex且密码为123时,显示登录成功,否则失败,失败时允许重复输入三次。

count = 0

while count < 3:
username = input("Please enter your username: ")
password = input("Please enter your password: ")
if username == "seven" and password == "123":
print("%s login successful." %username)
break
elif username == "alex" and password == "123":
print("%s login successful." %username)
break
else:
print("login failed.")
count += 1

if count == 3:
print("the max input is 3 times. ")
posted @ 2018-11-17 21:42  demilyc  阅读(3990)  评论(0编辑  收藏  举报