Write a progarm to adds every 3rd number in a list


Topic: Write a progarm to adds every 3rd number in a list

Solution

from functools import reduce
input_list = [x for x in range(10)]
reduce((lambda x, y: x + y), [val for idx, val in enumerate(input_list) if (idx+1)%3==0])



List all Python Programs