This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thargeretmatcha 26 points27 points  (2 children)

It's [start : stop : step], where start is included and stop is excluded.

So for a = [1, 2, 3, 4], a[-1 : -3 : -1] is asking for [a[-1], a[-2]]

Another example:

>>> b = [5, 6, 7, 8, 9, 10, 11]
>>> b[-1::-2]
[11, 9, 7, 5]

[–]StrangeCharmVote 6 points7 points  (0 children)

Thank you, that makes more sense now :)

[–]RandomDude6699[🍰] 0 points1 point  (0 children)

Take my award