Skip to content

Sum a list · ⁨求列表之和⁩

English

Sum a list

Add up every number in a list and return the total. Start a running total at 0, then loop over the list and add each value to it.

This pattern — a running total that grows inside a loop — comes up everywhere in programming.

中文

求列表之和

把列表中的每个数字加起来并返回总和。先把累加值设为 0,然后遍历列表,把每个值加上去。

这种模式 —— 在循环里不断增长的累加值 —— 在编程中随处可见。

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

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