python 3.x - Get user input within range while handling exceptions -


i trying user input number between 1 , 6 inclusive, , handle if put in non integar. here code below far cant seem work right. have tried can exceptions, try , if else statements within function no luck getting work :( please. got part of work when ask them enter number again don't know how code right exceptions keep working. took exceptions out because none of them worked. in advance

user_choice = int(input("enter choice: "))  if user_choice <= 6 , user_choice >= 1:     return user_choice  else:     print("invalid menu option.")     user_choice = int(input("please try again: "))     return user_choice 

user_choice = input("enter choice: ")  try:     user_int = int(user_choice) except valueerror e:     # user didn't enter integer!     print("please enter integernext time")  if user_choice <= 6 , user_choice >= 1:     print(user_choice) 

this should illustrate try / except clauses.


Comments