上QQ阅读APP看书,第一时间看更新
The len function
The len function expects a collection as input and returns the length of this collection—in other words, how many elements it consists of.
We measure the length of the string object in the following code, which is also iterable—you can think of it as a collection of characters:
>>> len('Hello')
5
Indeed, there are five characters in this word!