Part of the whole syntax error


#1

I know this topic is duplicate, but it seems I can't pass this round:

This is my answer, and I double-checked other similar topics. Still I got it wrong!

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

I don't know why this message appear: "Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected". Can anyone kindly explain this to me? Thanks!
`


#2

It's hard to tell since your code is not formatted properly, if all indentations are correct everything should work, append should be inside loop and return outside


#3

the problem is that you have to remove identation for return average(results)
so you have to return average after the function terminate.

in this code return is inside loop for , that generate the error

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