Greg Ewing <greg.ew...@canterbury.ac.nz> writes:

> On 6/08/21 12:00 pm, Jack Brandom wrote:
>> It seems
>> that I'd begin at position 3 (that's "k" which I save somewhere), then I
>> subtract 1 from 3, getting 2 (that's "c", which I save somewhere), then
>> I subtract 1 from 2, getting 1 (that's "a", ...), then I subtract 1 from
>> 1, getting 0 (that's J, ...), so I got "kcaJ" but my counter is 0 not
>> -13, which was my stopping point.
>
> You need to first replace any negative or missing indices with
> equivalent indices measured from the start of the string.
>
> When you do that in this example, you end up iterating backwards from 3
> and stopping at -1.

Yeah, that makes sense now.  But it sucks that the rule for replacing
negative indices is sometimes missing index and sometimes positive
index.  (That is, we can't always use positive indices.  Sometimes we
must use no index at all.  I mean that's how it looks to my eyes.)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to