None
is a valid element, but you can treat it like a stub or placeholder. So it counts as an element inside the list even if there is only a None
.
For (equality) comparisons you shouldn't use is
. Use ==
!
Because is
can lead to strange behaviour if you don't know exactly when and how to use it. For example:
>>> 1900 is 1900
True
>>> a = 1900
>>> b = 1900
>>> a is b
False
>>> a, b = 1900, 1900
>>> a is b
True
This rather strange behaviour is explained for example in this question: Why does Python handle '1 is 1**2' differently from '1000 is 10**3'?
This won't happen when you use ==
:
>>> a == b
True
>>> 1900 == 1900
True
like one would expect.