第二章练习题7c

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

user_name = "seven"
user_password = "123"
user_name2 = "alex"
user_password2 = "123"

count = 0
while count < 3:
    name = input("用户名:")
    password = input("密码:")
    if name == user_name and password == user_password or name == user_name2 and password == user_password2:
        print("登录成功")
        break
    else:
        print("登录失败")
        count +=1

猜你喜欢

转载自www.cnblogs.com/riling/p/10068785.html