Find the last element of a tuple using negative indexing

In this python tuple program, we will find the last element of a tuple using negative indexing.

Steps to solve the program
  1. Take a tuple as input.
  2. Find the last element of a tuple using tuple_name[-1].
  3. 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.

Leave a Comment