0
while True:
        if users_choice!= ('1','2','3','4','5'):
            print ('Insufficient input Method')
            break

This is inside my main loop. i dont want to place and if for each one.

  • 1
    Related: [How to test multiple variables against a value?](https://stackoverflow.com/q/15112125/451834109) – wjandrea Apr 12 '20 at 16:46

2 Answers2

3

Use users_choice not in ('1','2','3','4','5') instead.

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
0
while True:
    if users_choice not in ('1','2','3','4','5'):
        print ('Insufficient input Method')
        break

Operator != is actually trying to compare a string with tuple. That's why != wont work here.

To understand clearly, test this code

users_choice = '0'
while True:
    print(type(users_choice))
    print(type(('1','2','3','4','5')))

    if users_choice not in ('1','2','3','4','5'):
        print ('Insufficient input Method')
        break
ajayramesh
  • 3,576
  • 8
  • 50
  • 75