Slicing [N::-1]

Steven D'Aprano steve at
Fri Mar 5 19:22:59 CET 2010

On Fri, 05 Mar 2010 10:01:40 -0800, Joan Miller wrote:

> What does a slice as [N::-1] ?

Why don't you try it?

>>> s = "abcdefgh"
>>> s[4::-1]

The rules for extended slicing are not explained very well in the docs, 
and can be confusing. In my experience, apart from [::-1] it is best to 
always use a positive stride (the third number).


More information about the Python-list mailing list