寫代碼:實現用戶輸入用戶名和密碼,當用戶名爲seven且密碼爲123時,顯示登陸成功,不然失敗,失敗時容許重複輸入三次。

# 實現用戶輸入用戶名和密碼,當用戶名爲seven且密碼爲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("login successful.")
break
else:
print("login failed.")
count += 1

if count == 3:
print("the max input is 3 times. ")
相關文章
相關標籤/搜索