While working on a Python project for US clients, I often come across two operators, is and ==, that seem similar but have distinct purposes. In this tutorial, I will explain the difference between is and == in Python. Let us understand more about the topic with examples and screenshots of executed example code.
‘==’ in Python
The == operator is used to compare the values of two objects. It checks whether the values are equivalent, regardless of whether they are the same object in memory.
Example
a = [1, 2, 3]
b = [1, 2, 3]
print(a == b)
print(a is b) Output:
True
FalseI have executed the above example code and added the screenshot below.

In the example above, a and b are two different lists that contain the same values. The == operator returns True because the values are the same. However, the is operator returns False because a and b are different objects in memory.
ReadJavaScript vs Python for Web Development: Choosing the Right for Your Project
‘is’ in Python
The is operator checks for object identity. It returns True if two references point to the same object in memory.
Example
a = [1, 2, 3]
b = a
print(a == b)
print(a is b) Output:
True
TrueI have executed the above example code and added the screenshot below.

In this example, a and b are references to the same list object. Both == and is return True because they refer to the same object in memory.
Check out Difference Between “is None” and “== None” in Python
Key Differences
- Purpose:
==checks for value equality, whileischecks for identity. - Usage: Use
==when you need to compare the values of objects. Useiswhen you need to check if two references point to the same object. - Behavior with Immutable Types: Immutable types like integers and strings,
ismight seem to behave like==due to Python’s internal optimizations, but this is not guaranteed.
Examples
1. Compare Strings
a = "hello"
b = "hello"
print(a == b)
print(a is b) Output:
True
TrueI have executed the above example code and added the screenshot below.

For small strings, Python may use a technique called interning, where it reuses objects for efficiency. This can make is return True for small strings with the same value. However, this behavior should not be relied upon.
Read Python 3 vs Python 2
2. Compare Lists
a = [1, 2, 3]
b = [1, 2, 3]
print(a == b)
print(a is b)Output:
True
FalseLists are mutable, so a and b are different objects even if they contain the same values. Thus, == returns True, but is returns False.
Check out Difference Between = and == in Python
3. Compare Integers
a = 1000
b = 1000
print(a == b)
print(a is b) Output:
True
FalseHere, a and b have the same value, so == returns True. However, they are different objects in memory, so is returns False.
Read Jax Vs PyTorch
3. Use is with None
A common use case for is is to check if a variable is None.
a = None
if a is None:
print("a is None") Output:
a is NoneHere, is is used to check if a is None, which is more efficient and idiomatic than using ==.
Read Is Python an Interpreted Language
Summary Table
| Aspect | == | is |
|---|---|---|
| Purpose | Checks value equality | Checks object identity |
| Usage | Compare values of objects | Check if references point to the same object |
| Common Use Cases | Comparing numbers, strings, lists | Checking if a variable is None |
| Behavior with Immutable Types | Returns True if values are equal | May return True due to interning, but not guaranteed |
Conclusion
In this tutorial, I explained the difference between is and == in Python. We discussed what are “==” and ‘is‘ in Python with examples some key differences. I gave examples by comparing strings, lists, and integers, by using 'is' with None and given a summary for reference.
You may also like to read:
- Is Python a Compiled Language?
- Difference Between {} and [] in Python
- How to Comment Out a Block of Code in Python?

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.