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.
- Benefits of Double Division Operator over Single Division Operator in Python
- Ternary Operator in Python
- Python | Operator.countOf
- Operator Overloading in Python
- Walrus Operator in Python 3.8
- Operator Functions in Python | Set 1
- Operator Functions in Python | Set 2
- Python set operations (union, intersection, difference and symmetric difference)
- Python | List comprehension vs * operator
- Difference between Python and C++
- Difference between C and Python
- Difference between Python and C#
- Python Set | difference()
- Difference Between Python and Bash
- Difference between various Implementations of Python
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.