Itertools Blog Posts

Difference between reduce and accumulate

This article helps to give an introduction of reduce fuunction and accumulate function.Both the functions areĀ used to process the input_list as a sequential pairs.
I am going to explain the differences with the help of an example.
import functools
list = [1, 2, 3, 4, 5]
retVal = functools.reduce(lambda x, y: x+y, list)
print(retVal)
Result: 15

0 Likes 1216 Views