Slicing [N::-1]
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Mar 5 13:22:59 EST 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]
'edcba'
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).
--
Steven
More information about the Python-list
mailing list