Easy Tutorial
❮ Python Os Walk Ref Math Gamma ❯

Python3 List len() Method

Python3 List


Description

The len() method returns the number of elements in the list.

Syntax

Syntax for the len() method:

len(list)

Parameters

Return Value

Returns the number of elements in the list.

Example

The following example demonstrates the use of the len() function:

#!/usr/bin/python3

list1 = ['Google', 'tutorialpro', 'Taobao']
print(len(list1))
list2 = list(range(5)) # Creates a list from 0 to 4
print(len(list2))

The output of the above example is as follows:

3
5

Python3 List

❮ Python Os Walk Ref Math Gamma ❯