Python Practice › Tuple Programs › Program 24

Reverse a tuple

EasyTuple Programs · 24 of 70

Write a Python program to reverse a tuple.

Advertisement
Input
(4, 6, 8, 3, 1)
Output
(1, 3, 8, 6, 4) (1, 3, 8, 6, 4)

Approach

  1. [::-1] or tuple(reversed(t)).

Solution

Python
t = (4, 6, 8, 3, 1)print(t[::-1], tuple(reversed(t)))
Output
(1, 3, 8, 6, 4) (1, 3, 8, 6, 4)
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More tuple programs

← All 70 Tuple Programs