Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Python Membership Operators?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ = "Hello World"3Order
Put the learning moves in the order that makes the concept easiest to apply.
Membership operators are used to test if a sequence is presented in an object:
Membership in Strings
Membership Operators
Membership Operators
Membership operators are used to test if a sequence is presented in an object:
| Operator | Description | Example |
|---|---|---|
| in | Returns True if a sequence with the specified value is present in the object | x in y |
| not in | Returns True if a sequence with the specified value is not present in the object | x not in y |
Membership in Strings
The membership operators also work with strings:
Example
text = "Hello World"
print("H" in text)
print("hello" in text)
print("z" not in text)