I am currently creating a menu with try except
tools. I'm trying to create it so if a user enters nothing (presses ENTER) to output:
You have not entered anything, please enter a number between 1 and 4
This is what I've done so far:
def Menu():print("""Hello, please enter a number 1 - 41 - Compliment2 - Fact3 - Insult4 - Quit""")try:UserInput_INT = int(input("> "))except ValueError:UserInput_STR = (UserInput_INT)if len(UserInput_STR) == 0:print("You have entered nothing. Please enter a number between 1 and 4")print("You entered a character. Please enter a number between 1 and 4")Menu()if UserInput_INT not in range (1, 5):print("Invalid input please enter a whole number between 1 and 4")UserInput_STR = (str(UserInput_INT))if UserInput_STR == '1':print(" You look horrible today!")elif UserInput_STR == '2':print("Sam Birkenshaw & Jordan Ives can code better than Mr Bath. ")elif UserInput_STR == '3':print("You are bad at coding ")elif UserInput_STR == '4':quit()Menu()