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

sum

Prev: str | Up: __builtins__ | Next: super
Rel: abs, divmod, max, min, pow
Ref: docs.python.org — sum
Tags: #public #python3 #builtins


Import & Availability

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

Overview & Signature

sum(iterable, /, start=0)

Return the sum of a 'start' value (default: 0) plus an iterable of numbers When the iterable is empty, return the start value.

Usage

assert sum([1, 2, 3, 4]) == 10
assert sum([1, 2, 3], start=10) == 16

Gotchas

REPL Inspect

help(sum)

Linked from

Related notes