Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ def reduce(function, sequence, initial=_initial_missing):
Apply a function of two arguments cumulatively to the items of an iterable, from left to right.

This effectively reduces the iterable to a single value. If initial is present,
it is placed before the items of the iterable in the calculation, and serves as
a default when the iterable is empty.
it is placed before the items of the iterable in the calculation. If the iterable is empty and
initial is given, initial will be returned. If initial is not given and iterable contains only
one item, the first item is returned.

For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
calculates ((((1 + 2) + 3) + 4) + 5).
Expand Down
Loading