首先让我说,我是编码的入门者。我使用的是python 3.4.GUI。
所以我有以下代码:
register = input("have you registered an
account?")
if register == "yes":
print("you may proceed to log in")
if register == "no":
print("please, create an account")
else:
print("that is not a valid answer")
如何为此创建一个true循环,以便用户输入“是”或“否”以外的任何内容时,他们会重新开始使用? 谢谢!
答案 0 :(得分:1)
如果要在正确输入后结束循环,请取消注释中断。
while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")