Copyright © tutorialspoint.com

Python List len() Function

previous next


Description:

This function returns the number of elements in the list.

Syntax:

len(list)

Parameters:

Here is the detail of parameters:

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

Copyright © tutorialspoint.com