Membership & Identity Operators in Python
🟢 Beginner
📖 Definition
Membership operators (in, not in) test sequence inclusion. Identity operators (is, is not) test if two variables reference the exact same memory object.
âš¡ Code Example
nums = [1, 2, 3]
print(2 in nums) # True
a = [1]
b = [1]
print(a == b) # True (equal values)
print(a is b) # False (distinct memory objects)
🧠Navigation
← 05. Assignment & Walrus Operator | Operators Hub | Operators Hub →