Identity Operators
Operator
Meaning
Example
Example
x1 = 5
y1 = 5
x2 = "Hello"
y2 = "Hello"
x3 = [1, 2, 3]
y3 = [1, 2, 3]
print(x1 is y1) # True (small ints may be cached)
print(x2 is y2) # True (strings may be interned)
print(x3 is y3) # False (different list objects)
print(x3 == y3) # True (same contents)Note
Last updated