Membership Operators test for membership in a sequence, such as strings, lists, or tuples but in dictionary we can only test for presence of key, not the value.
Operator | Description | Syntax |
in | If a sequence with the specified value is present in the object. Returns True. | a in b |
not in | If a sequence with the specified value is not present in the object. Returns True. | a not in b |
Example:
a = "ProgramsBuzz"
print("g" in a)
print("d" not in a)
Output:
True True
Related Content
Tags