from functools import reduce my_list = [1,2,3] def accumalator(acc, item): print(acc, item) return acc + item print(reduce(accumalator, my_list, 10)) # What reduce does? # reduce take the function given and take item from the # iterable and pass to function given to it. The first # parameter is the value initialized as the 3rd argument # to the reduce function. It do the processing and returns # a value which is used as next initialiizing value for the # first argument of the function provided in the reduce function # and so on for all items in iterable.