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)
- Python | Operator.countOf
- Operator Overloading in Python
- Ternary Operator in Python
- Operator Functions in Python | Set 1
- Operator Functions in Python | Set 2
- Python Set | difference()
- Difference between C and Python
- Difference between various Implementations of Python
- Python | Difference between two lists
- Difference between Method and Function in Python
- Python | Difference between iterable and iterator
- Python | Difference in keys of two dictionaries
- Difference Between Go and Python Programming Language
- 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.