What is the difference between `is` and `==` in Python?

Python Professional Hard

Python Professional — Hard

What is the difference between `is` and `==` in Python?

Key points

  • `is` compares object identity, `==` compares object values
  • `is` is used for checking if two variables point to the same object
  • `==` is used for checking if the values of two variables are the same

Ready to go further?

Related questions