Python Practice › Tuple Programs › Program 35

Tuple at a given position

EasyTuple Programs · 35 of 70

Write a Python program to get the tuple at index i of a list of tuples.

Advertisement
Input
[(1, 2, 3), (6, 5, 4), (7, 6, 8), (9, 0, 1)], i = 3
Output
(9, 0, 1)

Approach

  1. Index the list.

Solution

Python
data = [(1, 2, 3), (6, 5, 4), (7, 6, 8), (9, 0, 1)]print(data[3])
Output
(9, 0, 1)
Advertisement

Learn the concept

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

More tuple programs

← All 70 Tuple Programs