Articles → Python → Is Operator In PythonIs Operator In PythonIn this article, we will discuss is operator in Python.Purpose The is operator checks whether both the operands refer to the same object or not.Example Consider the following example: -list1 = [] list2 = [] if list1 is list2: print("True") else: print("False")Here both list1 and list2 are pointing to different objects. So, the output will be False. Now change the above code.list1 = [] list2 = [] list2 = list1 if list1 is list2: print("True") else: print("False")In the above code, we are assigning the reference of list2 to list1. Once you run the above code, you will get True.Posted By - Karan Gupta Posted On - Friday, May 17, 2019 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
list1 = [] list2 = [] if list1 is list2: print("True") else: print("False")
list1 = [] list2 = [] list2 = list1 if list1 is list2: print("True") else: print("False")
Query/Feedback