Slicing [N::-1]

Mensanator mensanator at
Fri Mar 5 19:33:46 CET 2010

On Mar 5, 12:01 pm, Joan Miller <pelok... at> wrote:
> What does a slice as [N::-1] ?

Starts at position N and returns all items to the start of the
list in reverse order.

> It looks that in the first it reverses the slice and then it shows
> only N items, right?

Wrong. It shows N+1 items. Remember, counting starts from 0.

> Could you add an example to get the same result without use `::` to
> see it more clear?

for i in range(8,-1,-1):print(a[i],end=' ')

although I doubt this is more clear.

> Thanks in advance

More information about the Python-list mailing list