Python Practice › Tuple Programs › Program 24
Reverse a tuple
Write a Python program to reverse a tuple.
Input
(4, 6, 8, 3, 1)
Output
(1, 3, 8, 6, 4) (1, 3, 8, 6, 4)
Approach
[::-1]ortuple(reversed(t)).
Solution
t = (4, 6, 8, 3, 1)print(t[::-1], tuple(reversed(t)))Output
(1, 3, 8, 6, 4) (1, 3, 8, 6, 4)
Learn the concept
New to this topic? Read the lesson, then come back.