I am stuck on a problem that I am trying to solve. I am only suppose to take int (1-4) from user's input and not take any string/float/etc. I have figured out what to do if a user chooses any integer other than 1-4. However, I am stuck on the part where a user chooses anything other than an integer (i.e string, float, etc). this is what I have done so far:
def menu():
my code
menu()
# keeps on looping till user have selected a proper selection (1-4)
selection = int(input("> "))
if selection == 1:
my code
elif selection == 2:
my code
elif selection == 3:
my code
elif selection == 4:
my code
else:
print("I'm sorry, that's not a valid selection. Please enter a
selection from 1-4. ")
menu()
Any help would be appriciated. I've been trying to find a solution for hours but got stuck on the last part.