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 False
- 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.
- Output of the fourth if condition is “False” because concatenation of two list is always produce a new list.
This shows list1 and list2 refers to different objects.
- Benefits of Double Division Operator over Single Division Operator in Python
- Operator Functions in Python | Set 1
- Python | Operator.countOf
- Walrus Operator in Python 3.8
- Operator Overloading in Python
- Ternary Operator in Python
- Operator Functions in Python | Set 2
- Python | List comprehension vs * operator
- Python set operations (union, intersection, difference and symmetric difference)
- Python Set | difference()
- Difference between Python and C++
- Difference between C and Python
- Difference between Python and C#
- Difference Between x = x + y and x += y in Python
- Difference between 'and' and '&' in 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 firstname.lastname@example.org. 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.
Improved By : XAkash