Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Difference between == and is in Python

📅 2012-May-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

if i == j:
    # Do something
if i is j:
    # Do something

== operator checks the values behind the two names. It returns True if the two values are equal, False otherwise.

is operator checks the objects behind the two names. It returns True if both the names refer to the same object, False otherwise.

Tried with: Python 3.2