Python len() Function
The len() function returns the number of items (length) in an
object.
The object can be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
Syntax
len(object)
Parameters
| Parameter | Description |
|---|---|
object |
Required. An object. Must be a sequence or a collection |
Return Value
An integer representing the number of items in the object.
Example
Using the len() function with various types:
Output
Click Run to execute your code
Enjoying these tutorials?