Sum a list · リストの合計
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
This one builds on a lesson you haven't finished yet. Do that lesson first: · これはまだ完了していないレッスンの先にある内容です。まずはそのレッスンを済ませてください:
Python Basics · Functions →
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 から始め、リストをループして各値を加えていきます。
このパターン — ループ内で累加する合計値 — はプログラミング全体で頻繁に登場します。
Write sum_list(xs) that returns the total of all numbers in the list xs. An empty list sums to 0. · sum_list(xs) を書いて、リスト xs のすべての数字の合計を返してください。空のリストの合計は 0 です。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。