Computing the Average, what's wrong?


#1



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

def grades_sum(grades):
    sum = 0
    for i in grades:
        sum += i
    return 

def grades_average(grades):
    s = grades_sum(grades)
    a = s/float(len(grades))
    return a

print grades_average(grades)


Replace this line with your code.


#2

By the way, below is the message in the console window:
Traceback (most recent call last):
File "python", line 14, in
File "python", line 11, in grades_average
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'


#3

your first function should return sum, but call it total or result, since sum is built in function


#4

See you again :wink:
That's right, I got it right. Thanks very much.