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


#1

https://www.codecademy.com/en/courses/python-beginner-en-qzsCL/1/4?curriculum_id=4f89dab3d788890003000096


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!


#2

Your code is returning a list. Try,

return average(results)

#3

Hello
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))


#4

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