Python Tutorials · Python Operators
Membership Operators
Learn all about Membership Operators in this comprehensive tutorial.
5 min read beginner
- •Membership operators are used to test if a sequence is presented in an object:
- •The membership operators also work with strings:
Membership Operators
Membership operators are used to test if a sequence is presented in an object:
| Operator | Description | Example | Try it |
|---|---|---|---|
| in | Returns True if a sequence with the specified value is present in the object | x in y | Try it » |
| not in | Returns True if a sequence with the specified value is not present in the object | x not in y | Try it » |
Examples
python
python
Membership in Strings
The membership operators also work with strings:
python
Module quiz
2 questions1
Which of the following is true about Membership Operators?
2
What is the most common pitfall when working with Membership Operators?
Answer all questions to submit.