Python tuple index() is an inbuilt method that searched for a given element and returns the index of the element present in the array. If the occurrence of the element is more than one in the tuple, it returns the smallest index of the element.

Python Tuple index()

Python tuple index() method searches an element in a tuple and returns its index. In simple terms, the index() method searches for the given element in a tuple and returns its position. However, if the same item is present more than once, the first/smallest position is returned.

Syntax

tuple.index(element)

Here, the tuple is the name of the tuple, and the element is the value whose index is to be found.

Return Value

Python tuple index() method returns the index/position of the given element. If the element is not present in the tuple, it returns a ValueError.

#python #python tuple index

Python Tuple index() Function Example
10.45 GEEK