-2

Im trying to make it so that if user input is not 1-7 a print statement is made, otherwise if the user chooses a value from 1-7 a corresponding function takes place

this is what ive got so far,

if user_action != 1 or 2 or 3 or 4 or 5 or 6 or 7:    
    print("Please choose a valid action!")

else:
    if user_action == 1:
    one_item_information()
Kawehi
  • 7
  • 4
  • 1
    Or simpler `if 1 <= user_action <=7: one_item_information() else: print("Please choose a valid action!")` – Guy Jun 02 '22 at 07:56
  • Assuming you've made sure `user_action` is an `int`, the main problem is that `1 or 2 or ...` doesn't work how you think it does. You need `if user_action not in (1, 2, ...)` – Lecdi Jun 02 '22 at 07:57
  • fixed things up, thank you! – Kawehi Jun 02 '22 at 08:01

0 Answers0