Python Tutorials · Python Operators

Identity Operators

Learn all about Identity Operators in this comprehensive tutorial.

5 min read beginner
  • Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:

Identity Operators

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:

OperatorDescriptionExampleTry it
isReturns True if both variables are the same objectx is yTry it »
is notReturns True if both variables are not the same objectx is not yTry it »

Examples

python
python

Difference Between is and ==

  • **is** - Checks if both variables point to the same object in memory
  • **==** - Checks if the values of both variables are equal
python

Module quiz

2 questions
1

Which of the following is true about Identity Operators?

2

What is the most common pitfall when working with Identity Operators?

Answer all questions to submit.