bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python Membership Operators

Membership Operators

Membership operators are used to test if a sequence is presented in an object:

OperatorDescriptionExample
inReturns True if a sequence with the specified value is present in the objectx in y
not inReturns True if a sequence with the specified value is not present in the objectx 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)

Previous

Python Identity Operators

Next

Python Bitwise Operators