# The sum of scores

#1

It seems to me I have done the right thing yet I receive error message which says " It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned 97 instead of 287 for grades_sum([97, 14, 50, 48, 22, 56])". kindly help me with this. Thank you

``````Replace this line with your code.
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

total = 0
for i in scores:
total += i
print total

#2

97 is the first number in list, what a coincidence. So, for some reason our function ends in the first iteration of the loop

By default at the end a function returns None, if we want to return something different at the end of our function, we can use the `return` keyword

so, the function ends the moment a return keyword is reached, even when the return keyword is reached in the loop

#3

Ok.. although I understand your point, I still do not get how to solve the problem. Think you might elaborate a little bit more please?

#4

if you understand, you should understand the loop needs to run through all its iterations to get the correct total

so, given the `return` keyword is what ends the loop in the first iteration, what do we need to do?

#5

When I removed the `return` keyword it flagged this error: It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned None instead of 94 for grades_sum([5, 45, 44])

#6

the function still needs to return the total, but after the for loop has successfully added all values in list to total, not in the first iteration of the loop, which will end the function immediately (breaking the loop)

#7

Oh, I get it. Thank you for your help

#8