In this python tuple program, we will reverse a tuple.
Steps to solve the program
- Take a tuple as input.
- FIrst reverse the given tuple by using reversed() and then convert it to a tuple using tuple().
- 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)