Python List len() Method
Description
The len() method returns the number of elements in a list.
Syntax
The syntax of the len() method is:
len(list)
Parameters
- list -- The list for which to count the elements.
Return Value
Returns the number of elements in the list.
Example
The following example demonstrates the usage of 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 : 2Other Extensions
Python Lists