Can someone please help me with what is wrong with my code below, as I keep getting the error messgae “grades_variance([62, 35, 59, 74, 87]) returned 0.392 instead of the correct value 299.44


in the grades_variance function, we need to get the variance of each grade, and add it together. This is why we have a loop (line 21) then inside the loop, you get the variance of grade and add it together (line 22)

then outside/after the loop, you should calculate the result by dividing the total variance by the length of grades. (line 23), you do this, but inside the loop. Which isn’t right


I’m now getting this error message 'It looks like not all grades were printed! Make sure you are printing each one on their own line".

I’ve tried modifying the code variously to make it print each code on its ow line, but so far no luck.
Any pointers on what the issue is would be appreciated.


Okay finally solved. Replaced last six lines with;

print grades_sum(grades)
print grades_average(grades)
variance = grades_variance(grades)
print variance
print grades_std_deviation(variance)

Guess the “print_grades(grades)” did the trick. Still trying to figure out why though. I would be grateful for any pointers as to why so. Cheers


because its one of the requirements of the exercise/task? You needed to print all the grades, you built a function for it, as such the exercise expects you to use it


Okay but this is what I printed previously:

print grades(grades)

which kept returning the error message that I did not print each grade on its own line.

Since it accepts “print_grades(grades)” and not print grades(grades), so what then, as far as the code is concerned is the difference between the two?



print grades(grades)

is a function call which would attempt calling grades, but you do not have a function named grades. The function you want to called is named print_grades, look at your earlier code, do you see the function?


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