这是我拥有的代码:
choice = ""
while choice != "1" and choice != "2" and choice != "3":
choice = raw_input("pick 1, 2 or 3")
if choice == "1":
print "1 it is!"
elif choice == "2":
print "2 it is!"
elif choice == "3":
print "3 it is!"
else:
print "You should choose 1, 2 or 3"
虽然它能够正常工作,但我觉得循环条件特别笨拙。如果我有更多可接受的选择,有没有更好的方法来编写这个条件语句呢?
choice, "it is"
(?),还是这些确实是不同的情况? - Andy Hayden