Python tuple program to reverse a tuple

In this python tuple program, we will reverse a tuple.

Steps to solve the program
  1. Take a tuple as input.
  2. FIrst reverse the given tuple by using reversed() and then convert it to a tuple using tuple().
  3. Print the output.
				
					tup = (4,6,8,3,1)
print("Original tuple: ",tup)
tup1 = tuple(reversed(tup))
print("Reversed tuple: ",tup1)
				
			

Output :

				
					Original tuple:  (4, 6, 8, 3, 1)
Reversed tuple:  (1, 3, 8, 6, 4)
				
			

convert a tuple into a dictionary.

convert a list of tuples in a dictionary.

Leave a Comment