How to Access Tuple Items in Python


In this example we will show how to access tuple items by specifying a range of negative indexes in Python.

Source Code

my_tuple = ('a', 'b', 'c', 'd', 1, 2, 3, 4)

print(my_tuple[-6:-2])

Output:

('c', 'd', 1, 2)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

How to Access Tuple Items in Python


In this example we will show how to access tuple items by referring to the index number in Python.

Source Code

# the tuples are written with round brackets
my_tuple = ('a', 'b', 1, 2)

print(my_tuple[2])

Output:

1

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments