0
我的任務是創建一個程序,它可以重新檢查密碼和用戶名,它除了一個缺陷外都可以工作。如果用戶名或密碼不匹配,則顯示「再次輸入詳細信息」並按照我希望的方式循環顯示,但如果匹配,則中斷並停止程序,但在此之前顯示「再次輸入詳細信息」。我如何解決這個問題,如果用戶的細節匹配,然後打印「好!」就像我想要的那樣,而不是「像輸入細節一樣」輸入細節。即使結果不同,我的程序仍然循環一行
import time
complete = False
user = [["username",""],["password",""]]
def Access():
for n in range (len(user)):
user[n][1] = input(user[n][0])
while not complete:
Access()
username = input("Reinput the username?")
password = input("Reinput the password?")
if username == user[0][0]:
print("Good!")#what i want it to print if correct
else:
print("Input details again!")#what it keeps printing no matter what
if password == user[1][1]:
print("User has been identified, Welcome", username)
complete = True
break
[詢問用戶輸入的,直到他們得到一個有效的響應]的可能的複製(http://stackoverflow.com/questions/23294658/asking-the -user-for-input-until-they-give-a-valid-response) –
你應該在你的其他帖子中看到我的回答。解決那個問題 – abccd
沒有足夠的答案嗎? – abccd