[EMAIL PROTECTED] wrote:
>>> mystr = 'my string'
>
> I would have then thought of the contents of mystr as:
>
> indices0 1 2 3 4 5 6 7 8
> contentm y s t r i n g
>
> with mystr[:3] = 'my '
>
> Can someone explain to me how mystr[:3:-1] = 'gnirt'?
A slice [i:j:k] includes the first i
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm really confused about results of slices with negative strides. For
> example
>
>>>mystr = 'my string'
>
> I would have then thought of the contents of mystr as:
>
> indices0 1 2 3 4 5 6 7 8
> contentm y s t r i n g
>
> wi
On Oct 6, 1:05 pm, [EMAIL PROTECTED] wrote:
> I'm really confused about results of slices with negative strides. For
> example
>
> >>mystr = 'my string'
> ...
> Can someone explain to me how mystr[:3:-1] = 'gnirt'?
You've omitted the first number in the slice: python uses a sensible
default for it
I'm really confused about results of slices with negative strides. For
example
>>mystr = 'my string'
I would have then thought of the contents of mystr as:
indices0 1 2 3 4 5 6 7 8
contentm y s t r i n g
with mystr[:3] = 'my '
Can someone explain to me how mystr[:3:-1] = 'gnirt'?
I