Python 'is' versus 'equal'(==)
-
date_range 02/01/2019 00:00 infosortPython3-TutoriallabelPython3-tutorials
Hi There, In this post we’ll see some of the differances between is and equal (==) in python
Is Vs equal (==)
-
Example one:
>>> a = 1 >>> a == 1 True >>> a is 1 True >>> -
Example two:
>>> a = [1, 2, 3] >>> b = [1, 2, 3] >>> >>> a == b True >>> a is b False >>> ==: The equal (==) operator compars the values of a and bis: The is keyword Compars the stored memory addresses
