Reducer

Sat 17 May 2025

title: "Reducers" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import functools as fnt
list = [10, 40, 20, 50, 30, 90]
list
[10, 40, 20, 50, 30, 90]
sum_list = fnt.reduce(lambda x, y: x+y, list)
sum_list
240
def get_sum(list):
    return fnt.reduce(lambda x,y : x+y, list)
print(get_sum(list))
240

Score: 5

Category: basics