My last question was adding two consecutive numbers in a list . But answers are not generalized. How to add n
consecutive elements
in
a list. where n >= 2
if n = 3
l = [1,2,3,4,5,6] result = [6, 15]
l = [1,2,3,4,5,6,7] result = [6, 15, 7]
l = [1,2,3,4,5,6,7,8] result = [6, 15, 15]
if n = 4
l = [1,2,3,4,5,6,7] result = [10, 18]