The == operator compares the values of both the operands and checks for value equality. Whereas is operator checks whether both the operands refer to the same object or not.
True False True
- Output of the first if condition is “True” as both list1 and list2 are empty lists.
- Second if condition shows “False” because two empty lists are at different memory locations. Hence list1 and list2 refer to different objects. We can check it with id() function in python which returns the “identity” of an object.
- Output of the third if condition is “True” as both list1 and list3 are pointing to the same object.
This shows list1 and list2 refers to different objects.
- Python set operations (union, intersection, difference and symmetric difference)
- Operator Functions in Python | Set 1
- Python | Operator.countOf
- Ternary Operator in Python
- Operator Overloading in Python
- Operator Functions in Python | Set 2
- Walrus Operator in Python 3.8
- Python | List comprehension vs * operator
- Difference between Python and C#
- Difference between C and Python
- Python Set | difference()
- Python | Difference between two lists
- Difference between various Implementations of Python
- Python | Difference Between List and Tuple
- Python | Triple list difference
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.