Identity Operator

Last updated: Apr 12, 2026

Identity Operators

Use the Identity operator to check whether the value of two variables is the same or not. This operator is known as a reference-quality operator because the identity operator compares the values in the memory addresses of two variables. There are two identity operators.

  1. is : The is operator returns boolean values either True or False. It returns True if the memory address's first value is equal to the second value. Otherwise, it returns False.

  2. is not : The is not operator returns boolean values either True or False. It returns True if the first value is not equal to the second value. Otherwise, it returns False.

Operator Description Example Result Condition
is Is a is b True / False True if both point to same object in memory
is not Is not a is not b True / False True if they are different objects in memory

Example:

x = 10
y = 11
z = 10
 
print(x is y)      # it compare memory address of x and y
print(x is z)      # it compare memory address of x and z
print(x is not y)  # it compare memory address of x and y
print(x is not z)  # it compare memory address of x and z

Output:

False
True
True
False