Python Practice › Tuple Programs › Program 6
Element by index
Write a Python program to get an element of a tuple by its index.
Input
(4, 8, 9, 1), index 2
Output
9
Approach
- Square brackets with the index.
Solution
t = (4, 8, 9, 1)print(t[2])Output
9
Learn the concept
New to this topic? Read the lesson, then come back.