Sum Help


#1



My sum function appears fine and prints the correct answer when grades is used as an input.
However, when I run the code I receive the message 

"It looks like your grades_sum function doesn't properly compute the sum of all the grades! 
It returned None instead of 343 for grades_sum([76, 5, 2, 34, 52, 67, 69, 38])"

def grades_sum(scores):
    total = 0
    for i in scores:
        total += i
    print total

I do not understand this issue, but I cannot move on until it is corrected


#2

Instead of printing total return total!


#3

I have a almost the same problem - My code is:

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

def grades_sum(scores):

total = 0

for i in grades:

    total += i

return total

print grades_sum(grades)

AND THE ERROR IS:
Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned 1045.5 instead of 1 for grades_sum([1])


#4

Just forget it - I changed grades to score and now it works :slight_smile:


#5

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