Quick actions

cmd+k|ctrl+k

Navigation

Languages

reduce()

Snippet info

Language

Python

Visibility

public

Author

ankushsahu203

Created

2026-07-24T06:35:12.658808Z

Updated

2026-07-24T06:35:12.658808Z

from functools import reduce
my_list=[1,2,3]


# def  multiply_by2(item):
#     return item*2
    
# def check_odd(item):
#     return item%2 != 0 

def accumulator(acc,item):
    print(acc,item)
    return acc+item
print(reduce(accumulator,my_list,0))
print(my_list) #it doesn't change the list 
    


INFO