A
ajcppmod
I'm really confused about results of slices with negative strides. For
example
I would have then thought of the contents of mystr as:
indices 0 1 2 3 4 5 6 7 8
content m y s t r i n g
with mystr[:3] = 'my '
Can someone explain to me how mystr[:3:-1] = 'gnirt'?
I was expecting the result to be mystr[:3] reversed (' ym') i.e slice
then reverse or even the first 3 elements of the string after being
reversed ('gni') i.e. reverse then slice.
Thanks
Andy
example
I would have then thought of the contents of mystr as:
indices 0 1 2 3 4 5 6 7 8
content m y s t r i n g
with mystr[:3] = 'my '
Can someone explain to me how mystr[:3:-1] = 'gnirt'?
I was expecting the result to be mystr[:3] reversed (' ym') i.e slice
then reverse or even the first 3 elements of the string after being
reversed ('gni') i.e. reverse then slice.
Thanks
Andy