functools.reduce: Apply Function Cumulatively to the Items of Iterable

functools.reduce: Apply Function Cumulatively to the Items of Iterable

If you want to apply a function of two arguments cumulatively to the items of iterable from left to right, use functools’s reduce. This method reduces the iterable to a single value.

In the code below, 3 is the result of the function add_nums(2, 1). 3 is then used as the first argument of the function add_nums(3, 2).

Search

Related Posts

Related Posts

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran