Average


#1



grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
def grades_sum(grades):
    total=0
    for i in grades:
        total=total+i
    return total

def grades_average(grades): 
    return grades_sum/float(len(grades))

print grades_average(grades)

it returns error "TypeError: unsupported operand type(s) for /: 'function' and 'float'"

Is there something wrong with my code?
thanks!


#2

Hello @zoezhang1992foxmail,

Inside your grades_average function body, you are dividing grades_sum by float(len(grades)). However, you should really be calling grades on grades_sum and dividing that by float(len(grades)). Fix this up and you'll be good to go.


#3

aha i find that
sooo careless i am
thank you so much!