Skip to content

Running total

Running total

Add up the list [5, 10, 20] one number at a time, printing the total after each step: 5, 15, 35.

Lines indented under the for run every time round the loop; a line after the loop runs only once. Here the print belongs inside the loop.

Log in or create account

IGCSE, A-Level & AP