a simple question about the third index in slice

700MHz 700MHz at gmail.com
Fri Oct 21 02:29:38 EDT 2005


I cannot quite understand when the third index is a negative
number,like this:
a = '0123456789'
a[1:10:2] I know the index step is 2, so it will collect items from
offset 1, 3, 5, 7, 9
but when a negative number come,like:
a[1::-1] answer '10', and a[1:10:-1] only answer '',
what is the different between the two expression, where does the offset

begin and what is the end offset? 
Thanks!




More information about the Python-list mailing list