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 len() Function


previous next AddThis Social Bookmark Button


Description:

This function returns the number of elements in the list.

Syntax:

len(list)

Parameters:

Here is the detail of parameters:

  • list: a list for which number of elements to be counted.

Return Value:

It returns the number of elements in the list.

Example:

#!/usr/bin/python

list1, list2 = [123, 'xyz', 'zara'], [456, 'abc']

print "First list length : ", len(list1);
print "Second list length : ", len(list2);

This will produce following result:

First list length :  3
Second lsit length :  2


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names