Python Tuple index()

In this tutorial, you will learn about python tuple index() built-in method. It searches or find the tuple members or items and return the index number where item found.


The syntax of python tuple index() method is



tuple index() method can take three parameters.

Item: item which you want to search from tuple

starting point(Optional): It represent the index number where you want to start searching

ending index(Optional): It represent the index number , to search item upto this index number



Tuple index() method return the index of first matching item. I mean, an item is exist more than one time in tuple. Index() method will return index number of first appearance item in the tuple.

Note: Index numbering always start from zero, I mean, the index number of first element will be always zero(0), second element will be one(1) , third element will be two(2) and so on…..


See examples below to understand






In this example you will see, index() method just return the index of first appearance of an item





In this example we will use starting point parameter.  this will start searching the item ‘i’ from index number 3





In this example we will use all three parameters


index() method generate error if item, doesn’t exist in the tuple



Get More Python Tutorials

Python Tuples