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]

def print_grades(grades):

for grade in grades:

print grade

def grades_sum(grades):

total = 0

for grade in grades:

total += grade

return total

def grades*average(grades):
sum*of

*grades = grades*sum(grades)

average = sum

*of*grades / len(grades)

return average

def grades_variance(grades,average):

variance = 0

for g in grades:

variance += ((average - g) ** 2)

return variance / len(grades)

print grades*variance(grades, grades*average(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]
def print_grades(grades):
for grade in grades:
print grade
def grades_sum(grades):
total = 0
for grade in grades:
total += grade
return total
def grades_average(grades):
sum_of_grades = grades_sum(grades)
average = sum_of_grades / float(len(grades))
return average
def grades_variance(scores):
average=grades_average(scores)
variance=0
for score in scores:
variance += ((average-score)**2)
final_variance=variance/float(len(scores))
return final_variance
print grades_variance(grades)
```

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):
average=grades_average(scores)
variance=0
for score in scores:
variance += ((average-score)**2)
final_variance=variance/float(len(scores))
return final_variance
print grades_variance(grades)
```

##### 2 Comments

Can I have the whole code, cuz it still does not work . Thank you very much.

Tah very much brilliant code helped me out loads

## 4 Comments

Niloufer Othman over 4 years ago

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

Tommy Zhou over 4 years ago

thank you very much

Niloufer Othman over 4 years ago

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

salvador alvarez over 4 years ago

tanks!!!!!!!!!