image
image
image

Negative Indexing

image

Just like lists, tuples can also be indexed negatively.

Like lists, -1 refers to the last element on the list and -2 refer to the second last element.

Example

Start IDLE.

Navigate to the File menu and click New Window.

Type the following:

tuple_mine=[‘t’,’r’,’o’,’g’,’r’,’a’,’m’]

print(tuple_mine [-2])  #the output will be ‘a’