Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python List index() Method


previous next AddThis Social Bookmark Button


Description:

This method returns the lowest index in list that obj appears

Syntax:

list.index(obj)

Parameters:

Here is the detail of parameters:

  • obj: object to be find out.

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 Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names