Get_class_average() not working, no idea why


EDIT: Figured out that I was reassigning individual_ averages for each key, and had to make results.append part of the loop to add it each time.

Although, previously it was giving errors along the lines of "float cannot be used as parameter with append", and i've no idea why it would do that either. It also simply gave the error ([alice)] returned (the wrong average). I can't really replicate it because I've basically been repeatedly typing in what I though the code should be up until now.

Student Becomes the Teacher - Part of the Whole

I've had tons of errors on this, but the one I'm getting right now is "oops, get_class_average([alice, lloyd]) returned (lloyd's average) instead of (the average of both of them)",
Been at this for at least an hour, starting to go a little mad, would appreciate an explanation of why my code is faulty. :slight_smile:

def get_class_average(students)
      results = []
      for student in students
          individual_averages = get_average(student)
      return average(results)

By the way, is there any way to copy and paste the python code out of the thingy, using a mac and it is not working at all.


you need to use markup to make the indent show on the forum:

Has nothing to do with your mac.

Can you post an updated version of your full code with the correct indent?


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