Account
Categories

Python Tuple index() Method


Definition:

If you need to find the index of a specific value, you can use the index() method.

Syntax

tuple_name.index(value)

Example:

t = (11, 20, 40, 20)
print(t.index(20))

Output:

Note :

Index counting starts from zero and goes from left to right.

Exercise

Create a tuple t = (5, 10, 15, 10) and find the index of 10.