List Instead of Float


#1



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

Oops, try again. average([3, 0]) resulted in an error: float() argument must be a string or a number

My problem is that the variable total is somehow a list. Therefore, the float function won't work on it.
Any tips?


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]
}

# Add your function below!
def average(numbers):
    total = 0,
    total = sum(numbers),
    total = float(total),
    print total,
    total1 = float(total)/len(numbers),
    return total


#2

at this lines:

    total = 0,
    total = sum(numbers),
    total = float(total),
    print total,
    total1 = float(total)/len(numbers),
    return total

why do you use comma's everywhere?


#3

That was a mistake. I have since taken those out. This does still not change the problem.


#4

you return total which contain the total, you store the average in total1

you should return the average, not the total/sum


#5

Thank You this fixed it!


#6