Closed bolry closed 8 years ago
It's the difference between indexes (starting at zero) and ordinals (starting at one).
>>> a = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
>>> odds = a[::2]
>>> evens = a[1::2]
>>> print(odds)
['red', 'yellow', 'blue']
>>> print(evens)
['orange', 'green', 'purple']
odds = a[::2] gives you the first, third, and fifth items from the list
But thanks for the report!
item 6, page 13, technicality, odds = a[::2] actually only gives the even indexes (it starts with index 0 = even) and should therefor be evens = a[::2].
The same for evens = a[1::2] should be odds = a[1::2] since with start on the odd index 1.
Kind regards, Bo Rydberg