CodeAcademy - Python - Student Becomes Teacher 8/9 - Part of the Whole

python

Solution

The indentation of your `return` statement is wrong. Currently, it is returning after the first iteration of the loop. Here is the proper indentation:

def get_class_average(students):
    results = []
    for student in students:
        results.append(get_average(student))
    return average(results)

You can also simplify your code using list comprehension:

def get_class_average(students):
    return average(get_average(student) for student in students)

Problem

I assume that many of you are familiar with the CodeAcademy Python class. As the title says i am at the point where i have to get the average score of the class. Here it is what i did : ``` def get_class_average(students): results = [] for student in students: results.append(get_average(student)) return average(results) ``` the error i get is "Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected". And i can't seem to find my mistake for 5 hours now, so please take a look and tell me what is wrong with the code.

Original source

Related problems