1. 程式人生 > >練習: 三次機會登錄系統

練習: 三次機會登錄系統

NPU style put count () lse user print inpu

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

練習: 三次機會登錄系統