Just weight and see



File "python", line 31
return (homework * 0.1) + (quizzes * 0.3) + (tests * 0.6)
SyntaxError: invalid syntax

I don't understand why it's giving me a syntax error. I feel as though the code is correct.

def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"]
    return homework * 0.1 + quizzes * 0.3 + tests * 0.6


The arrow points to where the interpreter stopped parsing. The error will be just before that.


OH! I see the issue now. Thank you so much. I was unaware that it would place an error after the error. That almost seems silly. Thanks for the help!


When we think about it, it makes perfect sense. The statement being parsed is unexpected, so parsing ceases at that point. However, the cause of the error, or exception is in the previous statement. That's what gave rise to the unexpected statement or expression.


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