Python Practice › Tuple Programs › Program 21

Index of an element

EasyTuple Programs · 21 of 70

Write a Python program to find the index of an element in a tuple.

Advertisement
Input
("s", "q", "a", "t", "o", "o", "l", "s"), "a"
Output
2

Approach

  1. index().

Solution

Python
t = ("s", "q", "a", "t", "o", "o", "l", "s")print(t.index("a"))
Output
2
Advertisement

Learn the concept

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

More tuple programs

← All 70 Tuple Programs