Please help me find the error


#1



What is wrong with the following code? The error message says:
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 170 for grades_sum([2, 66, 45, 57])
While on the console window it says:
1045.5
None

How do i fix this?


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

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


#2

Make sure you return total at the end of function.


#3

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