Tuples: Accessing Items
Syntax: tuple[index]
E.g.
>>> t = (1, 2, (3, 4, 5))
>>> t[1]
2
>>> t[-1]
(3, 4, 5)
>>> t[-1][1]
4
>>> t[3]
Traceback (most recent call last):
File "
", line 1, in ?
t[3]
IndexError: tuple index out of range
Previous slide
Next slide
Back to first slide
View graphic version