Latest web development tutorials

Python List len ​​() method

Python list Python list


description

len () method returns the number of list elements.

grammar

len () method syntax:

len(list)

parameter

  • list - a list of the number of elements to be calculated.

return value

Returns the number of elements in the list.

Examples

The following example shows len () function to use:

#!/usr/bin/python

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

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

Examples of the above output results are as follows:

First list length :  3
Second lsit length :  2

Python list Python list