练习: 三次机会登录系统

name = "ken"
pwd = "123"
count = 3
while 1 <= count:
    user_name = input("输入姓名:").strip()
    user_pwd = input("输入密码:").strip()
    if user_name == name and user_pwd == pwd:
        print("登录成功")
        break
    elif 1 < count:
        print("输入的姓名或密码有误,请重新输入")
        count = count - 1
    else:
        print("三次机会用完")
        break

猜你喜欢

转载自www.cnblogs.com/kenD/p/9424963.html