Just Weight and See


#1

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

I am not sure why my code is not executing. It looks right to me.

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 = sum(numbers)
    total = float(total) 
    total/len(numbers)

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

I need help with the last function "get_average". For some reason I keep getting an error that says "get_average(alice) raised the following error: unsupported operand type(s) for *: 'NoneType' and 'float'"

Can someone please help me with this?


#2

HI in this function its missing the return statement

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

to total/len(numbers)


#3

Thank you, the code worked. I don't know why the return statement got deleted from earlier.