question about slicing with a step length

John Salerno johnjsal at
Thu Mar 9 05:04:07 CET 2006

André wrote:

> An extended slice of list x of length n in the form x[j:k:i] selects
> every i-th element starting with and including the element at index j

This makes it sound like the index of 10 should be inclusive.

> When either index is missing or lies outside of the
> list bounds, the minimum or maximum inclusive index is used
> automatically.

So does that mean that the example actually is wrong, and Python is 
compensating? I tried numbers[9:0:-2] and it returned the same value as 
if I had used 10 as the first index, so perhaps 10 shouldn't be there 
after all.

More information about the Python-list mailing list