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
Test your knowledge on this module
2 questions