my name is Ana Baird, and I'm writing a program with the try and except block. I have to ask the user for input in selecting a number between 1 and 12, but what if a user inputs a number 0 or a 13? Or any number bigger than 12? What kind of error should I type in the except block to catch this error?
Also, in a new def function, I have to put a menu and print it out, so how do I first print the menu so that the user can see it before they can select a number from that menu? This menu has to be inside the function?
So, for instance, this is my attempt with the second issue:
userInp = int(input("Please enter a number between 1 and 12 from the menu: ")
def printMenu()
menu = print("\t\t1)Category\n\t\t2)Item\n\t\t3)Serving Size\n\t\t4)Calories")
A third issue: How do I ask a user to input a number from 1 to 12 and keep asking that user to keep entering input until they input "done"? I tried with the while loop but it just keeps going into an infinite loop of a print statement, like
"you selected Item
you selected Item
You selected Item
..."
and so on
Any ideas? I appreciate the help, thank you! Also, please make it a simple program, not an overcomplicated one, I'm just a beginner, thank you.
Sincerely, Ana Baird