Python3 List len() Method
Description
The len() method returns the number of elements in a list.
Syntax
len() method syntax:
len(list)
Parameters
- list -- the list whose elements are counted.
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'
]
(
len
(
list1
)
)
list2
=
list
(
range
(
5
)
)
Create a list of 0-4
(
len
(
list2
)
)
The output of the above example is:
3
5
The Python3 list