1

How do we do it in python if I want to find if x is equal to any object inside a list?

something like

if x == list[any]:
    do something
Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
edrichhans
  • 83
  • 1
  • 2
  • 10

1 Answers1

6

Simpler:

In [1]: lst = [1, 2, 3]

In [2]: 3 in lst
Out[2]: True

In [3]: 4 in lst
Out[3]: False
vaultah
  • 40,483
  • 12
  • 109
  • 137