- 1
Why print(range(0,100)[::-2] == range(99,0,-2)) prints true?
3 ответов
+ 8
Things get even more weird. In Python 3.2 that statement prints out False, while in Py3.6 - prints True.
range(0, 100)[::-2] is range(99, -1, -2) and so for Python 3.2 it is different than range(99, 0, -2). Python 3.6 does not recognize this difference, as both ranges are equal, element-wise.
+ 4
@ Kuba according to the documentation this is because:
Changed in version 3.3: Define ‘==’ and ‘!=’ to compare range objects based on the sequence of values they define (instead of comparing based on object identity).
+ 1
in 3.4 it is also True.
it seems logical to return True,
as both ranges return the same values