---
title: "Explain the difference between \"is\" and \"==\" operators in Python."  
description: "Explain the difference between \"is\" and \"==\" operators in Python."  
author: "Utpal Vishwas"  
published: 2023-06-26  
updated: 2023-06-27  
canonical: https://www.mindstick.com/forum/158875/explain-the-difference-between-is-and-operators-in-python  
category: "python"  
tags: ["python", "programs"]  
reading_time: 2 minutes  

---

# Explain the difference between "is" and "==" operators in Python.

[Explain the difference](https://www.mindstick.com/forum/156125/can-you-explain-the-difference-between-organic-and-paid-results) between "is" and "==" [operators](https://www.mindstick.com/articles/716/php-operators) in Python.\

## Replies

### Reply by Aryan Kumar

Sure. The `is` and `==` operators in Python are used to compare objects, but they do so in different ways.

The `is` operator compares the **identity** of two objects, while the `==` operator compares the **equality** of two objects.

- **Identity** refers to whether two objects are the same object in memory.
- **Equality** refers to whether two objects have the same value.

For example, the following code will print `True` because the two variables `a` and `b` refer to the same object in memory:

Python

```plaintext
a = 10
b = 10

print(a is b)
```

However, the following code will print `False` because the two variables `a` and `c` refer to different objects in memory, even though they have the same value:

Python

```plaintext
a = 10
c = 10

print(a is c)
```

The `==` operator, on the other hand, will always return `True` if two objects have the same value, regardless of whether they are the same object in memory. For example, the following code will print `True` for both `a is b` and `a == c`:

Python

```plaintext
a = 10
b = 10
c = 10

print(a is b)
print(a == c)
```

In general, you should use the `is` operator when you want to check whether two variables refer to the same object, and you should use the `==` operator when you want to check whether two objects have the same value.

Here is a table that summarizes the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between the `is` and `==` operators in Python:

| Operator | Meaning |
| --- | --- |
| `is` | Compares the identity of two objects |
| `==` | Compares the equality of two objects |


---

Original Source: https://www.mindstick.com/forum/158875/explain-the-difference-between-is-and-operators-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
