第二章练习题7b

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

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

猜你喜欢

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