Home >>Python Tuple Methods >Python Tuple index() Method
Python index() method is used to find the first occurrence of the specified value in the given input tuple. It raises an exception if the specified value is not found.
Syntax:tuple.index(value)
Parameter | Description |
---|---|
value | This is a required parameter. It defines the item to search for. |
thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5)
x = thistuple.index(8)
print(x)
a = ['Abhi', 'Mickey', 'Jerry', 'Abhi', 'Cobra', 'Alpha', 'Abhi']
X = a.index("Jerry")
print(X)