Computing the Average - you did not print the correct average error


I'm not sure what's wrong with this and haven't found an answer that applies to my situation; from other post. I have tried float in many areas, but my result = 1.0 should be handling this anyways.

The average returned is 80.5, so I really can't put my finger on the bug here. Thanks for your help.

"You did not print the correct average." --error

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

def grades_sum(scores):
    for s in scores:
        result += s
    return result

def grades_average(grades):
    average = (grades_sum(grades)) / len(grades)
    return average

print grades_average(grades)


I skipped to the next task and found out how they have defined the functions. I copied that and used it in the previous task.

I can see now the average is actually 80.4230769231. So, my code that produces 80.5 is clearly incorrect.


I also get the same output i guess we float in the second def function it shows in 80.42....
my code is different from urs

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

print grades_average(grades)


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