In my program I have a menu that looks like this:
MenuChoice = ''
while MenuChoice != 'x':
print("Type 1 to enter the first option")
print("Type 2 to enter the second option")
print("Type 3 to enter the third option")
print("Type 4 to enter the fourth option")
print("Press x to quit")
try:
MenuChoice = str(input("Please enter your choice here ----------------->>>>>"))
except ValueError:
print("Please enter one of the menu choices above, TRY AGAIN ")
I just want to know a way in which I can insure that only the numbers 1 to 5 are accepted and that if anything else is entered then the program asks the question again.
Please dont roast me.
Thanks