STUDENT BECOMES THE TEACHER: Part of the Whole


#1

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

The code is supposed to output the average of Lloyd, Alice and Tyler, but it keeps giving the wrong output.

The error message it keeps popping up is: "get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected "


#2

It is hard to see the problem if the code it not shown with proper indents/format.
But I'm guessing that your return average(results) is not indented properly. Does it line up with your for loop like this?:

...
for item in students:
    results.append(get_average(item))
return average(results)
...

#3

4 posts were split to a new topic: Part of the Whole problem


#4