Ich versuche, ein Login-Menü zu machen. Ich habe ein Benutzer/Pass-System erstellt, das änderbar ist. Aber ich möchte irgendwie aus der Schleife herauskommen, um sie zu bitten, ihren Benutzernamen/Passwort erneut einzugeben? HierPython - Wie komme ich aus einer While-Schleife?
ist der Quellcode:
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' dort. – miradulo
Das sind sehr große Einbuchtungen ... –
Brechen funktioniert nicht? Es beendet nur das Programm. – HazardGames