Write a program to adds every 5th number in a list
Topic: Write a program to adds every 5th number in a list
Solution
input_list = [x for x in range(20)] res=reduce((lambda x, y: x + y), [val for idx, val in enumerate(input_list) if (idx+1)%5==0]) print('Sum of every 5th element in the list is', res)
List all Python Programs