Python List len() method
Description
The len() method returns the number of elements in a list.
Syntax
len() method syntax:
len(list)
Parameters
- list -- the list whose elements are counted.
Return Value
Returns the number of elements in the list.
Example
The following example shows how to use the len() function:
#!/usr/bin/python
list1, list2 = [123, 'xyz', 'zara'], [456, 'abc']
print "First list length : ", len(list1);
print "Second list length : ", len(list2);
The output of the above example is:
First list length : 3
Second lsit length : 2
Python Lists