CKTIS / Python
Operator in
Tests whether a container contains the given member.
Version: Python 3.14; repository image, production runtime not attested
Syntax
left in rightTests whether a container contains the given member.
Use membership to search for a key, sequence element or substring according to the right operand. On a string the left operand must itself be a string.
Python first tries the containment protocol and can fall back to iteration or indexed access. Searching a one-pass iterator consumes input up to the match or exhaustion.
Membership in a dictionary searches keys, even when the sought object appears as a value.
Syntax
left in right
__contains__, __iter__, __getitem__ · in
Worked example
"x" in {"x": 7} → True
7 in {"x": 7} → False
"bc" in "abc" → True
3 in "123" → TypeError
Examples
print("id" in {"id": 42})
print(42 in {"id": 42})
Result
True False
Membership in a dictionary searches keys, even when the sought object appears as a value.