Code works on Sublime text but not on the Codeacademy platform


#1



Write a function called get_average that takes a student dictionary (like lloyd, alice, or tyler) as input and returns his/her weighted average.

Define a function called get_average that takes one argument called student.
Make a variable homework that stores the average() of student["homework"].
Repeat step 2 for "quizzes" and "tests".
Multiply the 3 averages by their weights and return the sum of those three. Homework is 10%, quizzes are 30% and tests are 60%.


The error is this one: Oops, try again. get_average(alice) returned 0.0 instead of the expected 91.15


It works perfectly when I try it on Sublime Text but not in the platform which is pretty weird.

What am I doing wrong? https://gyazo.com/394299492889d572c137ef96ad20c855


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(student):
    homework = float(sum(student["homework"]))/len(student["homework"])
    quizzes = float(sum(student["quizzes"]))/len(student["quizzes"])
    tests = float(sum(student["tests"]))/len(student["tests"])
    fixedTotal = homework*(10/100) + quizzes*(30/100) + tests*(60/100)
    return fixedTotal


#2

Seems you're missing the average function.


#3

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