In this python tuple program, we will find the last element of a tuple using negative indexing.
Steps to solve the program
- Take a tuple as input.
- Find the last element of a tuple using tuple_name[-1].
- Print the output.
tup = ('p','y','t','h','o','n')
print("Original tuple: ",tup)
print("Last element of the tuple using negative indexing: ",tup[-1])
Output :
Original tuple: ('p', 'y', 't', 'h', 'o', 'n')
Last element of the tuple using negative indexing: n
check the type of the input and return True if the type is a tuple and False if it is not a tuple.