description
The Python len () method returns the length of an object (characters, lists, tuples, etc.) or the number of items.
grammar
Syntax of len () method:
len( s )
parameter
- s-object.
return value
Returns the object length.
Examples
The following example shows how to use len ():
>>>str = "runoob"
>>> len(str) # 字符串长度
6
>>> l = [1,2,3,4,5]
>>> len(l) # 列表元素个数
5