boB Stepp <robertvst...@gmail.com> writes:

> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
>           ^    ^    ^    ^    ^   ^
>           -5   -4   -3   -2   -1  ?

For completeness, let's use the rest of the integers also::

              0    1    2    3    4    5
              ↓    ↓    ↓    ↓    ↓    ↓
    mylist = [ 100, 200, 300, 400, 500  ]
              ↑    ↑    ↑    ↑    ↑    ↑
             −5   −4   −3   −2   −1    ?

> But in this model, what should go in the place of "?"?

You can use ‘len(mylist)’ for the index at the end of the sequence.

There isn't a negative number which will address that position; it isn't
needed, because there is already one obvious way :-)

-- 
 \            “Without cultural sanction, most or all of our religious |
  `\          beliefs and rituals would fall into the domain of mental |
_o__)                                 disturbance.” —John F. Schumaker |
Ben Finney

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to