Why doesn't this work?


#1



https://www.codecademy.com/en/courses/python-beginner-en-qzsCL/1/2?curriculum_id=4f89dab3d788890003000096

Oops, try again. get_average(alice) raised the following error: sum expected at most 2 arguments, got 3


lloyd = {
    "name": "Lloyd",
    "homework": [90.0, 97.0, 75.0, 92.0],
    "quizzes": [88.0, 40.0, 94.0],
    "tests": [75.0, 90.0]
}
alice = {
    "name": "Alice",
    "homework": [100.0, 92.0, 98.0, 100.0],
    "quizzes": [82.0, 83.0, 91.0],
    "tests": [89.0, 97.0]
}
tyler = {
    "name": "Tyler",
    "homework": [0.0, 87.0, 75.0, 22.0],
    "quizzes": [0.0, 75.0, 78.0],
    "tests": [100.0, 100.0]
}
def get_average(n):
    total=sum(n)
    total=float(total)
    total=total/float(len(n))
    return total
def get_average(student):
    homework=average(student["homework"])
    quizzes=average(student["quizzes"])
    tests=average(student["tests"])
    homework=homework*.1
    quizzes=quizzes*.3
    tests=tests*.6
    return sum(homework,quizzes,tests)


#2

Have you read the error message that you posted? It seems to answer your question!


#3

I tried fixing it with
sum(sum(a,b),c), still doesn't work.
Floats cannot be iterated?


#4

No they can't. Floats are just a single value, there is nothing to iterate through.

Consider what input sum takes, look up the documentation for it by googling "python built-in functions"

Or call help with sum as the argument

Or consider what it is you're trying to make happen on that line and see if you don't know a simpler way of doing it. You should figure out what's wrong about it though.