5. It`s Okay to be Average


#1



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


Oops, try again. average([3, 0]) returned 3.0 instead of 1.5 as expected.


Hey, I don`t know what I`m doing wrong. I think there is a stupid mistake from my side, but I can`t recognize where. Please give me an advice :wink:


Replace this line with your code. 

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


#2

your division:

total  / len(numbers)

you don't store the result of this division anywhere


#3

Thanks a lot :slight_smile: My mistake was in bad stored sum(numbers)

I changed for

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

total = float(total)
total = float(total) / len(numbers)
return total

#4