7/9 Syntax Error in def?


#1

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

print grades_variance(grades)

This keeps diving me:
File "python", line 18
def grades_variance(scores):
^
SyntaxError: invalid syntax

and I don't understand why the def function is invalid. Can anyone help?


#2

you forgot to call the function grades_average(scores) at the beginning. Your code its correct but you need this line after your def starts average = grades_average(scores). It will look like:

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

print grades_variance(grades)


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

print grades_variance(grades)

if you need the correct indentation it looks like the above code