4. The sum of scores


#1




Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned None instead of 533 for grades_sum([47, 67, 87, 75, 89, 69, 99])


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

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

Hei guys, while I run the program I get the correct result but it keeps giving me that error. Anyone could help?
Thanks


#2

@moltivie ,

You have this ...

print total

... instead of a return statement. Without a return statement, the value returned by the function will always be None, even if the function prints the correct result.


#3

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