Membership operators in python.

Membership operators

in and not in are the membership operators in Python. They are used to test whether a value or variable is found in a sequence (stringlisttupleset and dictionary).

In a dictionary we can only test for presence of key, not the value.

Operator Meaning Example
in True if value/variable is found in the sequence 5 in x
not in True if value/variable is not found in the sequence 5 not in x
Posted on by