Message358656
`-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 |
|
Date |
User |
Action |
Args |
2019-12-19 04:33:04 | zach.ware | set | recipients:
+ zach.ware, NNN |
2019-12-19 04:33:04 | zach.ware | set | messageid: <1576729984.8.0.87245063853.issue39095@roundup.psfhosted.org> |
2019-12-19 04:33:04 | zach.ware | link | issue39095 messages |
2019-12-19 04:33:04 | zach.ware | create | |
|