
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Explain difference between == and is operator in Python.
== operator
== operator compares the operands by checking the equality of values of objects.
is operator
is operator compares the operands by checking the objects to be the same or not.
Example
Following is the program in Python to showcase the difference.
list1 = [1] list2 = [1] list3 = list1 print(id(list1)) print(id(list2)) if (list1 == list2): print("True") else: print("False") if (list1 is list2): print("True") else: print("False") if (list1 is list3): print("True") else: print("False")
Output
140380664377096 140380664376904 True False True
- Related Articles
- Difference between == and is operator in python.
- What is the difference between operator and method on Python set?
- Difference between == and === operator in JavaScript
- Difference between !== and ==! operator in PHP
- Difference between "new operator" and "operator new" in C++?
- What is the difference between working of append and + operator in a list in Python?
- Difference between concat() and + operator in Java
- Difference between != and !== operator in JavaScript Program
- Difference between the and$ operator in php
- Difference between the AND and && operator in php
- Difference between the Ternary operator and Null coalescing operator in php
- What is the difference between the dot (.) operator and -> in C++?
- What is the difference between equals() method and == operator in java?
- Difference between the | and || or operator in php
- Explain function of % operator in Python.

Advertisements