Python Tuple index() Method

Example

Retrieve the first occurrence of the value 8 and return its position:

thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5)
x = thistuple.index(8)
print(x)

Run Instance

Definition and Usage

The index() method finds the first occurrence of the specified value.

If the value is not found, the index() method will raise an exception.

Syntax

tuple.index(value)

Parameter Value

Parameter Description
value Required. The item to be retrieved.