Skip to content

Running total · ⁨累计求和⁩

English

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.

中文

累计求和

把列表 [5, 10, 20] 中的数逐个相加,每加一次就打印一次当前总和:5、15、35。

缩进在 for 下面的行每一轮都会运行;循环后面的行只运行一次。这里的 print 应该放在循环里面。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩