Part of a whole


Oops, try again. get_class_average([alice]) resulted in an error: global name 'student' is not defined

Not sure why I am getting this error, I have followed exactly how others have done in the past.

def get_class_average(students):
    for stundent in students:
        return results.append(get_average(student))
    return average(results)


Ok so I see I spelt STUDENT as "stundent" so after fixing that I now got this error ....

Oops, try again. get_class_average([alice]) should return a number

How do I fix this?



remove the return keyword.

Let me know if this resolves. :wink:


Thanks, that worked, can you explain what it was doing with the return there and now what it is doing with it gone.


It was returning (exiting the function) on the first iteration. It should be accumulating (appending) list elements until the loop is finished.


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