Documentation

Function defined in library functools

reduce(functionsequence)

reducefunctionsequence

Repetedly call a function with the elements of a sequence from left to right, accumulating the result.

Optionally, an initial value can be used to start the accumulation.

functionA function that combines the accumulated value with an element of the sequence

sequenceA sequence of elements

The accumulated value
Code
reduce(lambda acc, s: acc + ' ' + s, ['PyTamaro', 'is', 'cool'])
Result
'PyTamaro is cool'

See also reduce in the official documentation

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version 7c19cd0 (Thu, 04 Dec 2025 07:19:38 GMT)