Please help! 8/9 Part of the Whole: get_class_average([alice]) should return a number


Please help! I'm working on 8/9: Part of the Whole and when I submit the code, I receive this message:
"get_class_average([alice]) should return a number"

Below is my code:

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

Can anyone help point out what's wrong with this?
Many thanks!


Your code is returning a list. Try,

return average(results)


For the line : results = results.append(get_average(student))
There is no need to assign the append function to results twice.
results.append takes care that the new items are added to the list results.
So the code should be : results.append(get_average(student))


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