我对python很陌生。我需要反复循环,要求用户选择一个选项,然后运行命令并重复,直到用户选择退出。如果用户选择任何其他选项,程序必须不断要求他们选择一个值,直到他们选择一个正确的值。到目前为止,我的计划进展不顺利。如果可能的话,我想保持 while,if,elif 条件。有人可以提供帮助吗?非常感谢!
print """
How do you feel today?
1 = happy
2 = average
3 = sad
0 = exit program
"""
option = input("Please select one of the above options: ")
while option > 0 or option <=3:
if option > 3:
print "Please try again"
elif option == 1:
print "happy"
elif option == 2:
print "average"
elif option == 3:
print "sad"
else:
print "done"