Chapters
Python114 chapters

ReferenceTuple methods

tuple.index()

The position of the first matching item in a tuple.

Signature

values.index(item)

Parameters

NameMeans
itemwhat to look for

Returns

An int. Raises ValueError when absent.

Example

Python
values = (1, 2, 3)
print(values.index(3))

Output

2

See also