我有这个 while 循环正在测试以确保用户输入 1、2 或 3。一旦用户输入 1、2 或 3,循环就会无限循环,我无法摆脱它。
while True:
try:
filterselection = raw_input("Please select a filter (1, 2, or 3): ")
if filterselection == "1" or filterselection == "2" or filterselection == "3":
filterselection = int(filterselection)
break
else:
print "Not a valid number try again!"
except TypeError:
print "Lol, that's not a number try again!"