This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zach.ware
Recipients NNN, zach.ware
Date 2019-12-19.04:33:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576729984.8.0.87245063853.issue39095@roundup.psfhosted.org>
In-reply-to
Content
`-1` is not out of bounds unless the array is empty; negative indices count from the other end:

>>> a = list("some array")
>>> a
['s', 'o', 'm', 'e', ' ', 'a', 'r', 'r', 'a', 'y']
>>> a[-1]
'y'
>>> b = []
>>> b[-1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range



See about halfway down this [1] section; look for "Indices may also be negative".

[1] https://docs.python.org/3/tutorial/introduction.html?highlight=Indices+negative+numbers#strings
History
Date User Action Args
2019-12-19 04:33:04zach.waresetrecipients: + zach.ware, NNN
2019-12-19 04:33:04zach.waresetmessageid: <1576729984.8.0.87245063853.issue39095@roundup.psfhosted.org>
2019-12-19 04:33:04zach.warelinkissue39095 messages
2019-12-19 04:33:04zach.warecreate