写代码:实现用户输入用户名和密码,当用户名为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. ")


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM