7/9 Variances , Help


#1



https://www.codecademy.com/courses/python-intermediate-en-7mgOa/2/1?curriculum_id=4f89dab3d788890003000096


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)


#2

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


#3

thank you very much.


#4

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