我正在为游戏或其他东西或其他代码编写一个模拟注册页面,在代码结尾处我想确认用户输入的数据是否正确。我通过键入来做到这一点。如何从一开始循环一个程序
#User sign up page.
#Getting the user's information.
username = input ("Plese enter your first name here: ")
userage = input ("Please enter your age here: ")
userphoneno = input ("Please enter your home or mobile number here: ")
#Showing the inforamtion.
print ("\nIs the following correct?\n")
print ("•Name:",username)
print ("•Age:",userage)
print ("•Phone Number:",userphoneno)
#Confirming the data.
print ("\nType Y for yes, and N for no. (Non-case sensitive.)")
answer = input ("• ")
if answer == 'Y'or'y':
print ("Okay, thank you for registering!")
break
else:
#Restart from #Getting the user's information.?
我的问题出现在代码的最后一节。当输入“Y或y”时程序就会正常结束,但如果输入“N或n”,我似乎无法解决如何让用户输入数据。我尝试了一个While循环,我猜是解决方案,但我似乎无法让它正常工作。
任何帮助将不胜感激。谢谢!
向我们展示您尝试的while循环?另外,答案=='Y'or'y''将始终评估为真。看看[这](http://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values)。 –