4 ms·
Examples b and c on test #6 is something you should NEVER do in Python. Using "is" checking for integers is a huge no-no, and will only work for smaller integer
by jhgg 12y ago
Examples b and c on test #6 is something you should NEVER do in Python. Using "is" checking for integers is a huge no-no, and will only work for smaller integers (I think between -5 and 256) that are cached by the interpreter. "is" does identity checking, not equality checking.
>>> a = 500
>>> b = 500
>>> a is b
False
>>> a == b
True
>>> a = 2
>>> b = 2
>>> a is b
True
>>> a == b
True