len()Easy Examples

Returns the number of items in a container

Basic len() usage

Simple demonstration of the len() built-in function.

python
print(len("Hello"))
print(len([1, 2, 3, 4, 5]))
print(len({"a": 1, "b": 2}))

len() is a built-in function that returns the number of items in a container.

len() with different inputs

Calling len() with various argument types.

python
# More len() examples
print("len() is a Python built-in function")
print(f"Type: {type(len)}")

len() accepts different types of arguments and produces corresponding results.

Want to try these examples interactively?

Open Easy Playground