【发布时间】:2016-05-22 19:28:11
【问题描述】:
我正在尝试制作登录菜单。我创建了一个可更改的用户/通行证系统。但我想退出循环,让他们再次输入他们的用户名/密码?
这里是源代码:
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离开那里。 -
那是很大的缩进...
-
破解不起作用?它只是退出程序。
标签: python loops while-loop