How to Access Tuple Items with Negative Indexing in Python


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

Source Code

my_tuple = ('a', 'b', 1, 2)

print(my_tuple[-2])   # -2 refers to the second last item

Output:

1
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments