Most novice programmers when using these comparison operators believe they are the same thing. You’ll probably find they give the same answer in most cases but there will come a time when that isn’t the case and you’ll be left scratching your head. Today I want to clear up that misunderstanding. Let’s see where these operators will give the same answer and where they won’t. >>> a = [1, 2, 3, 4]>>> b = a>>> a == bTrue>>> a is bTrue So what’s the difference? Let’s look at another example: >>> a = [1, 2, 3, 4]>>> b = [1, 2, 3, 4]>>> a == bTrue>>> a is bFalse That’s some interesting behavior. Let’s take a closer look at whats going on under the hood. I’d like to point out, that Python lists are a lot more complicated than arrays but I will not be talking about their CPython implementation here. However if you are interested in understanding how they are implemented I highly recommend checking out by Laurent Luce. this post When you assign a list to a variable, like in the above example, Python allocates memory for that list BUT the actual list isn’t what is stored in our variable. Instead, Python creates a list object and stores a reference to that object in the variable. Essentially our variable now the list as seen below: a points to ‘a’ references (points to) a list In our first example we said This means that is referencing which references our list object. They are now referencing the same object. b = a. b a ‘a’ and ‘b’ reference (point to) the same list Now to distinguish and ‘==’ ‘is’. . Let’ say we had a factory producing T-Shirts. If two T-Shirts are produced and held next to each other, we couldn’t tell them apart. So we would say the two T-Shirts are ‘==’ checks for equality ‘==’. . With our two T-Shirts, we know they are not the same thing. So we would say that T-Shirt 1 is T-Shirt 2 is false. ‘is’ checks for identity With python, it’s basically the same thing except with the ‘is’ operator we check references. In our first example, ‘ ’ returns because what ever is referencing contains the exact same things that is referencing AND ‘ ’ returns because both and are referencing the same list object. a == b true a b a is b true a b However, with our second example we said a = [1, 2, 3, 4] and b = [1, 2, 3, 4] This creates a list object and stores a reference to it in a, then it creates a second list object and stores a reference to it in b. is still . However, is now . This is because both and now reference . This can be observed below: ‘a == b’ true ‘a is b’ false a b different objects ‘a’ and ‘b’ reference (point to) different list objects. In summary ‘is’ returns True if the operands reference the same object. ‘==’ returns True if the contents of the objects referenced by the operands are equal.