我正在嘗試創建登錄菜單。我創建了一個可更改的用戶/通行證系統。但是我想要退出循環,要求他們再次輸入他們的用戶名/密碼?Python - 如何擺脫while循環?
這裏是源代碼:
print ("Welcome, please login.")
username = input("Please set a username")
password = input("Please set a password")
print ("please can you login")
username_input = input("What is your username?")
password_input = input ("What is your password?")
if username_input == username and password_input == password:
while 1==1:
print ("1. Change username")
print ("2. Change password")
print ("3. Go back to login menu")
print ("4. Exit")
option = int(input("Please select an option, 1/2/3/4?"))
if option == 1:
username = input("Enter a new username")
print ("You username is now",username)
elif option == 2:
password = input("Enter a new password")
print ("Your password is now",password)
elif option == 3:
#Help
elif option == 4:
quit()
'break'離開那裏。 – miradulo
那些是非常大的縮進... –
打破不起作用?它只是退出程序。 – HazardGames