Write a program that filters a list for even numbers only and returns their sum


Topic: Write a program that filters a list for even numbers only and returns their sum

Solution

def map_reduce(lst):
    return reduce(lambda x, y: x + y, filter(lambda x: x % 2 == 0, lst))
print(map_reduce([1, 2, 3, 4, 5]))



List all Python Programs