This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Can anyone help me? Thanks! （Solved! 100% right!!）

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

total = 0

sum
return average

variance = 0
for g in grades:
variance += ((average - g) ** 2)
return variance / len(grades)

I do not know why my code did not work and i tried other people's solution, but it kept saying "ooops, try again".
Hope someone can give me a right solution.
Thanks

Hi,

Maybe it is your indentation?

Here is the whole code:

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

total = 0

return average

variance=0
for score in scores:
variance += ((average-score)**2)
final_variance=variance/float(len(scores))
return final_variance
``````

Niloufer Othman almost 5 years ago

the instructions i got told me to use scores as an argument.

Tommy Zhou almost 5 years ago

thank you very much

Niloufer Othman almost 5 years ago

no problem.. i hope it worked for you this time

salvador alvarez almost 5 years ago

tanks!!!!!!!!!

can i ask why you decided to use two arguments in your definition for grades_variance?

here is my solution that worked, hopefully it will help you

``````def grades_variance(scores):
variance=0
for score in scores:
variance += ((average-score)**2)
final_variance=variance/float(len(scores))
return final_variance