Last modified: Jan 10, 2023 By Alexander Williams
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
We and our partners share information on your use of this website to help improve your experience. For more information, or to opt out click the Do Not Sell My Information button below.