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.
ผลรวมสะสม
บวกรายการ [5, 10, 20] จำนวนหนึ่งตัวเลขในครั้งหนึ่ง, พิมพ์ผลรวมหลังจากแต่ละขั้นตอน: 5, 15, 35.
บรรทัดที่ย่ออยู่ใต้ for จะรันทุกครั้งที่วนรอบลูป; บรรทัดหลังจากลูปจะรันเพียงครั้งเดียว ที่นี่ print อยู่ ภายใน ลูป
Loop over nums and keep a total. After adding each number, print the total so far: 5, then 15, then 35. · วนลูปกับ nums และเก็บผลรวม เมื่อเพิ่มเลขแต่ละตัวแล้ว ให้พิมพ์ผลรวมปัจจุบัน: 5, แล้ว 15, แล้ว 35
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่