Just Weigh and See, Error


#1

def average(numbers):
total = sum(numbers)
total = float(total)

  avg = total/len(numbers)

  return avg

  def get_average(student):
    homework = average(student["homework"]
    quiz = average(student)["quizzes"]
    tests = average(student)["tests"]

fin = homework*0.1   +  quiz*0.3  +  tests*0.6
return fin

I am getting a syntax error, I cant understand what i have done wrong

File "python", line 31
quiz = average(student)["quizzes"]
^
SyntaxError: invalid syntax


#2

GOT IT

def get_average(student):
homework = average(student["homework"])
pls = average(student["quizzes"])
tests = average(student["tests"])

fin = homework*0.1   +  pls*0.3  +  tests*0.6
return fin

Sorry to waste your time, I messed up with some () brackets


#3

You got the Output without Errors?

I am getting this error

Oops, try again. get_average(alice) raised the following error: global name 'students' is not defined


#4

I'm getting the same problem. Beside that, code works independently.


#5

did you use 'student' as an argument for the get_average function?


#6

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