On this page
  1. len
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

len

Prev: iter | Up: __builtins__ | Next: license
Rel: all, any, enumerate, filter, iter
Ref: docs.python.org — len
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import len

Overview & Signature

len(obj, /)

Return the number of items in a container.

Usage

assert len([1, 2, 3]) == 3
assert len("café") == 4
assert len("café".encode("utf-8")) == 5

Gotchas

REPL Inspect

help(len)

Linked from

Related notes