# 4: The Sum of Scores

#1

Here's my code:

``````grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

total = 0
for numbers in scores:
total += numbers

I get this error message "Oops, try again.
35, 63])"

However I cannot understand why it doesn't add the values for the scores_list into the total.

Thanks if you can help!

#2

A function ends the moment a `return` keyword is reached, if the return keyword is reached in a loop, the loop will break so the function can end

So, your loop breaks in the first iteration

#3

I do understand what the problem is, but not how to fix it:
if I print the total instead of returning it, I have the correct digits on the display, but It wouldn't work if I end the loop after the print.
How could i do?

#4

first step in solving a problem, is understanding the problem. So you took a first good step

You could place return outside the loop so the whole loop can run?

#5

It works just fine, thanks for the advice!

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.