Documentation

Function from 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 3c97eb0 (Wed, 14 May 2025 17:27:27 GMT)