7/9 Variances , Help



Oops, try again. grades_variance([1, 4, 1, 2, 3, 1, 1, 1]) returned 0.5625 instead of the expected: 1.1875

How to solve this problem? and where is the fault in my coding? thank you

def grades_variance(scores):
    average = grades_average(scores)
    variance = 0
    for score in scores:
        variance += ((average-score)**2)
        return variance
    variances =  variance/float(len(scores))
    return variances
print grades_variance(grades)


a function ends the moment a return keyword is reached, if a return keyword is reached is in a loop, the loop breaks


thank you very much.


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