Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 List len() Method

Python3 List len() Method

Python3 Lists The Python3 list


Description

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

Syntax

len() method syntax:


len(list)

Parameters

Return Value

Returns the number of elements in the list.

Example

The following example shows how to use the len() function:

Example

#!/usr/bin/python3

list1

=

[

'Google'

,

'Runoob'

,

'Taobao'

]

print

(

len

(

list1

)

)

list2

=

list

(

range

(

5

)

)

Create a list of 0-4

print

(

len

(

list2

)

)

The output of the above example is:


3
5

Python3 Lists The Python3 list