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
  • 1,048,767
  • 296
  • 4,058
  • 3,343
edrichhans
  • 113
  • 1
  • 2
  • 11

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
  • 44,105
  • 12
  • 114
  • 143