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
Last modified: Jan 10, 2023 By Alexander Williams
tuple[-1]
#tuple
animals = ('cat', 'dog', 'zebra', 'shark')
#get last element of tuple python
print(animals[-1])
output
shark