Difference between == and is operator in Python Last Updated : 04 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In Python, == and is operators are both used for comparison but they serve different purposes. The == operator checks for equality of values which means it evaluates whether the values of two objects are the same. On the other hand, is operator checks for identity, meaning it determines whether two variables point to the same object in memory.== OperatorTo compare objects based on their values, Python's equality operators (==) are employed. It calls the left object's __eq__() class method which specifies the criteria for determining equality. However, these constraints are typically written so that the equality operator == returns True if two objects, have the same value and returns False if both have different value. Python x = [1, 2, 3] y = [1, 2, 3] z = x # Equality comparison (==) if x == y: print("True") else: print("False") Explanation:x == y checks if both lists have the same values. Since both lists contain [1, 2, 3], the output will be True.‘is’ OperatorPython identity operators (is, is not) are used to compare objects based on their identity. When the variables on either side of an operator point at the exact same object, the "is" operator's evaluation is true. Otherwise, it would provide us with a false assessment.Code Example of == operator and ‘is’ Operator : Python x = [1, 2, 3] y = [1, 2, 3] z = x # Case 1: Identity comparison (is) if x is y: print("True") else: print("False") # Case 2: Comparing references (is) if x is z: print("True") else: print("False") OutputFalse True Explanation:Case 1: x is y checks if x and y refer to the same object in memory. Since x and y are two separate list objects, the output will be False.Case 2: x is z checks if x and z refer to the same object. Since z is assigned to x, they are the same object, and the output will be True.Comparison:Parametersis Operator== OperatorNameThe ‘is’ is known as the identity operator.The ‘==’ is known as the equality operator.UsesThe is operator checks if two variables point to the same object in memory. It returns True if both variables are referring to the exact same object. If they point to different objects, even if the values are the same, it returns False.When the variables on either side have the exact same value, the == operator evaluation is true. Otherwise, it will evaluate as False. Comment More infoAdvertise with us K Kuldip Kumar 1 Follow Improve Article Tags : Python python-basics Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 7 min read Python Functions 5 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Dictionaries in Python 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 6 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 11 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like