I'm very new to python. I need to repeatedly loop, asking the user to select an option, then running the commands and repeating until the user chooses to exit. If the user selects any other option, the program must keep asking them to select a value until they choose a correct one. So far my program is not going that well. I'd like to keep to the while,if,elif conditions if possible. Is someone able to assist? Many thanks!
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"
inputin Python 2 is a bad idea concerning security. Useraw_inputand cast the result to anint(or just work with strings).