I want to add elements in a list every ten elements. For example:
a = [5, 31, 16, 31, 19, 5, 25, 34, 8, 13, 17, 17, 43, 9, 29, 41, 8, 24,
48, 1, 28, 20, 37, 40, 32, 35, 9, 36, 17, 46, 10, 30, 49, 28, 2, 3, 8,
11, 36, 20, 7, 24, 29, 15, 0, 4, 35, 11, 42, 7, 28, 40, 31, 45, 6, 45,
15, 27, 39, 6]
So I want to create a new list with the sum of every 10 elements, such as:
new = [187, 237, 300, 197, 174, 282]
Where the first entry corresponds to the add up of the first 10 numbers:
x = sum(5, 31, 16, 31, 19, 5, 25, 34, 8, 13)
x = 187
The second one to the 10 numbers in the range 10-19:
y = sum(17, 17, 43, 9, 29, 41, 8, 24, 48, 1)
y = 237
And so on; is there an efficient way to do this?