Copyright © tutorialspoint.com

Python List index() Method

previous next


Description:

This method returns the lowest index in list that obj appears

Syntax:

list.index(obj)

Parameters:

Here is the detail of parameters:

Return Value:

It returns index of the found object otherwise raise an exception indicating that value does not find.

Example:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc'];

print "Index for xyz : ", aList.index( 'xyz' ) ;
print "Index for xxx : ", aList.index( 'zara' ) ;

This will produce following result:

Index for xyz :  1
Index for xxx :  2

previous next

Copyright © tutorialspoint.com