How to Access Tuple Items in Python


In this example, we will learn 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
Advertisement