CJCoding With Joseph
15free / daySign inCreate account

Sum Of A List By Loop

Complete sum_of(values: list[int]) -> int so it returns the total of every number in the list, using a for loop that adds each element to a running total; do not use the built-in sum. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: a count on the first line, then that many integers one per line; the tests read them, build the list, pass it to your function and print the value it returns. An empty list gives 0.

Expected Output:

15

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Functions
📥 Auto-Input:
3\n4\n5\n6\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.