On Sat, Aug 7, 2021 at 5:22 AM Boris Dorestand <bdorest...@example.com> wrote:
>
> Jach Feng <jf...@ms4.hinet.net> writes:
>
> >> >>>>> s = "Jack Brandom"
> >> >>>>> s[3 : -13 : -1]
> >> >> 'kcaJ'
> >> >> I have no idea how to replace that -13 with a positive index. Is it
> >> >> possible at all?
> > That's not possible because a positive index is relative to the leftmost 
> > item 0
>
> And the middle index is always exclusive, so we can't go to the left of
> 0 and remain positive.  Okay, I think that answers it.  It's not
> possible at all.
>

An absent index isn't the same as any specific positive value, so,
yeah, it's not possible to replace it with a positive index. It IS
possible to replace it with None.

>>> s = "Jack Brandom"
>>> s[3:None:-1]
'kcaJ'

You could implement equivalent logic in your function.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to