Web Analytics

Python len() Function

Built-in Function Sequence

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

Related Functions