Why does this code return an error?


#1



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


File "python", line 23
return variance
^
SyntaxError: invalid syntax


Why does it return an error when I try to return the variance?


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


#2

look at the parentheses on the line above the error, they don't match


#3

Thank you. Now it doesn't return the right value but let's see if I can work that out


#4

It would be good if you could work that out yourself, if you need help, post an updated version of your code and i will help you


#5

I solved it but thank you for your help :slight_smile:


#6

always better if you solve it yourself :slight_smile:


#7

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