Last modified: March 30, 2020

get the last element of tuple in python

syntax


tuple[-1]

example


#tuple
animals = ('cat', 'dog', 'zebra', 'shark')

#get last element of tuple python
print(animals[-1])

output

shark