Python3 List len() Method
Description
The len() method returns the number of elements in a list.
Syntax
The syntax of the len() method is:
len(list)
Parameters
- list -- A list whose number of elements is to be calculated.
Return Value
Returns the number of elements in the list.
Example
The following example demonstrates the usage of the len() function:
Example
#!/usr/bin/python3
list1 = ['Google', 'Example', 'Taobao']
print (len(list1))
list2=list(range(5)) # Create a list from 0 to 4
print (len(list2))
list1 = ['Google', 'Example', 'Taobao']
print (len(list1))
list2=list(range(5)) # Create a list from 0 to 4
print (len(list2))
The output of the above example is:
3 5Other Extensions
Python3 Lists