
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between 'and' 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
Advertisements