Copyright © tutorialspoint.com
This method returns the lowest index in list that obj appears
list.index(obj) |
Here is the detail of parameters:
obj: object to be find out.
It returns index of the found object otherwise raise an exception indicating that value does not find.
#!/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 |
Copyright © tutorialspoint.com