len()

The built-in function that returns how many items a string, list, tuple, set or dictionary holds.

In more detail

len("hello") is 5 and len([]) is 0. The last index of a sequence is its length minus one. Your own classes can support len by defining __len__.

Example

len("Mississippi")

Related terms

Taught in

References

Certification courses