Python – How to check if an input is in a list in python

listpython

I want to be able to enter a value and check if it is in a list and if it is then in the list run a the rest of the program wanted.

a=input('enter value')
b=(1,2,3,4)
c=(5,6,7,8,9)
if a is in b:
   print 'enter in code thats wanted'

Best Answer

You've written it yourself almost correctly, just instead of -

if a is in b:

it should be -

if a in b: