Comparing with the previous value

Predict the output · Challenge · §7.2, §7.3 Building up

This code counts the days when the temperature rose from the day before. Predict the output without running the code.

Code

temps = [18, 21, 19, 24, 26]
up = 0
for i in range(1, len(temps)):
    if temps[i] > temps[i - 1]:
        up += 1
print(up)

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.