Lesson 6
Dealing with Sequences of Objects
Chapter 3: More on lists
List membership operator
The membership operator (in
) can be used to check whether a particular object is in a list. This returns a bool
(so True
or False
).
>>> print(3 in [1, 2, 3, 4])
True
>>> print(3 not in [1, 2, 3, 4])
False
>>> print("snake" in ["I", "am", "not", "afraid", "of", "Python"])
False
Try it out!
❮
❯