# 7/9 Program runs, but is not returning the correct answer

#1

The program runs but is not returning the correct answer for 'variance'.

```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:
print variance
variance += (average - score)**2
variance /= float(len(scores))
return variance

#2

Hi Joseph, I had the same problem as you, but then I realised it said "Divide the total variance by the number of scores."
So the variance division shouldn't be part for the loop:

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

I hope this helps.

#3

I have the same problem - program runs, but is not returning the correct answer.
Have struggles debugging it, without much success. Can somebody suggest a solution, please?

variance = 0

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

#4

This works:

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

#5
``````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
variance = variance /float(len(scores))
return variance