← Back to Functions
Question 320
Sum Of A List By Loop
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
Sign in to use hintsTopics:
Functions
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.