Python3 List len () method
description
len () method returns the number of list elements.
grammar
len () method syntax:
len(list)
parameter
- list - a list of the number of elements to be calculated.
return value
Returns the number of elements in the list.
Examples
The following example shows len () function to use:
#!/usr/bin/python3 list1 = ['Google', 'w3big', 'Taobao'] print (len(list1)) list2=list(range(5)) # 创建一个 0-4 的列表 print (len(list2))
Examples of the above output results are as follows:
3 5