Problems with Lesson 8. Part of The whole


#1



I'm currently stuck in Student Becomes The Teacher, lesson 8. Part of the Whole.


The feedback is giving me this error:

Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected

So it seems to be taking in only Alice's average and not adding the others to the results listing.
I cannot figure out why?


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)
    result= total / len(numbers)
    return result
print average (tyler["homework"])
print average (alice["tests"])

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

print get_average(lloyd)
print get_average(alice)
print get_average(tyler)

def get_letter_grade(student):
    score = get_average(student)
    if score >= 90:
        return "A"
    elif score >= 80:
        return "B"
    elif score >= 70:
        return "C"
    elif score >= 60:
        return "D"
    else:
        return "F"

print get_letter_grade (lloyd)
print get_letter_grade (alice)
print get_letter_grade (tyler)

students = [lloyd, alice, tyler]
def get_class_average(students):
    results = []
    for student in students:
        studentaverage = get_average(student)
        results.append(studentaverage)
        return average(results)  

print get_class_average(students)


#2

Could you post the link to that excercise here?


#3

a function ends the moment a return keyword is reached, if a return keyword is reached in a loop, the loop will break.

place return outside the for loop


#4

Thank you, this was the error!


#5