Python length of list


Python List is a collection of elements. The length of the List can vary. To check the length of the list len() function is used in Python.

Basic Syntax

Following is the basic syntax for abs() function in Java:

int len(list)

And the parameters are:

Parameter Description
list The list whose length will be counted

Return Value

Python len() function returns count of elements in given list.

Examples

Following are the examples for len() function in Python.

Example 1

# Python program to demonstrate working 
# of len() 
newlist = ["One","Two","Three","Four","Five","Six","Seven"] 
 
print("Length of list is: ", len(newlist)) 

The output should be:

Length of list is: 7

Following are the examples for len() function in Python.

Example 1

# Python program to demonstrate working 
# of len() 
b = [2.5,3.2,1.1] 
 
print("Length of list is: ", len(newlist)) 

The output should be:

Length of list is: 3