What would be the best way to write a new list where the new list is based on (is the average of) several elements from the previous list? Is a regular for-loop the only solution?
For example, the average of each two consecutive elements,
a= [4,2,5,3,2]
Output:
a_ave=[3, 3.5, 4, 2.5]
(4+2)/2=3, (2+5)/2=3.5, etc.