Running total · Total cumulatif
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.
Total cumulé
Ajoutez la liste [5, 10, 20] un nombre à la fois, en affichant le total après chaque étape : 5, 15, 35.
Les lignes indentées sous for s'exécutent à chaque passage dans la boucle ; une ligne après la boucle ne s'exécute qu'une seule fois. Ici, le print se trouve à l'intérieur de la boucle.
Loop over nums and keep a total. After adding each number, print the total so far: 5, then 15, then 35. · Parcourez nums et gardez un total. Après avoir ajouté chaque nombre, imprimez le total jusqu'à présent : 5, puis 15, puis 35.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.