Lists: Accessing Items
Syntax: list[-index]
Indexing from the right starts at -1
E.g.
>>> l = [1, ["2", 4], 3.0]
>>> l[-1]
3.0
>>> l[-3]
1
>>> l[-4]
Traceback (most recent call last):
File "
", line 1, in ?
l[-4]
IndexError: list index out of range
Previous slide
Next slide
Back to first slide
View graphic version