Element by index

EasyTuple Programs · 6 of 70

Write a Python program to get an element of a tuple by its index.

Advertisement
Input
(4, 8, 9, 1), index 2
Output
9

Approach

  1. Square brackets with the index.

Solution

Python
t = (4, 8, 9, 1)print(t[2])
Output
9
Advertisement

Learn the concept

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

More tuple programs

← All 70 Tuple Programs