Short solution using sum and enumerate functions:
tab = [80,12,14,5,70,9,26,30,8,12,16,15] sums = [sum(tab[i:i+4]) for i, v in enumerate(tab) if i+4 <= len(tab)] print(sums) The output:
[111, 101, 98, 110, 135, 73, 76, 66, 51] The last "4-items" consequent sequence to be summed up is 8,12,16,15(gives 51)