Identity Operators
Identity operators are used to check if two values are located on the same part of the memory.
| Operator | Description | Example |
|---|---|---|
is |
True if the operands are identical (refer to the same object) |
x is True |
is not |
True if the operands are not identical (do not refer to the same object) |
x is not True |
Examples
a = 10
b = 20
c = a
print(a is b) # False
print(a is not b) # True
print(a is c) # True
print(c is a) # True
print(a is not c) # False
print(c is not a) # False
print(a is a) # True
print(a is not a) # False
print(b is b) # True
print(b is not b) # False