Computing the average: why won't my float work?


Whenever I use the function at the end of the page, my window returns : Object of type 'float' has no len(). why is that? I followed the instructions alongside the window as mentioned.

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

def grades_sum(scores):
    for i in range(0, len(scores)):
    return total
def grades_average(grades):
    print avg
print grades_average(grades)



You have to be careful when you use the same name for the same things because you start to get into namespace issues.

Correct this issue and your code will function properly.

Also, there is a neat built in function called sum() that calculates a list of numbers total.

a = [1, 2, 3, 4, 5, 6]
# 21