N = 10
K = 2
Temps = [3, -2, -4, -9, 0, 3, 7, 13, 8, -3]

current_sum = sum(Temps[:K])
max = current_sum

for i in range(K, N):
    current_sum = current_sum - Temps[i - K] + Temps[i] 
    if current_sum > max:
        max = current_sum

print(max)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: