Python Practice › Tuple Programs › Program 21
Index of an element
Write a Python program to find the index of an element in a tuple.
Input
("s", "q", "a", "t", "o", "o", "l", "s"), "a"Output
2
Approach
index().
Solution
t = ("s", "q", "a", "t", "o", "o", "l", "s")print(t.index("a"))Output
2
Learn the concept
New to this topic? Read the lesson, then come back.