Part of the whole 8/9


Guys this is my code, could someone help me out?

def get_class_average(students):
    for student in students:
    return average(results)
    print get_class_average(students)
    print get_letter_grade(get_class_average(students))

This is my error message: Oops, try again. get_class_average([alice]) resulted in an error: list indices must be integers, not str




the get_average function is designed to calculate the average of one student. what is students? it is a list contains multiply students, get_average() is not designed to handle that.

(ignoring for a second that the function calls are inside the function)


so, I only had to change students to student... Thanks!
What do you mean with the function calls are inside the function?


but do you also understand why this change is important and how it works?

    print get_class_average(students)
    print get_letter_grade(get_class_average(students))

these function calls (^) are inside the function. Function calls should be outside/after the functions (unless you want recursion, which you don't in this case)


Yes because otherwise get_average would try to take several arguments at once and not after another, right?

ah yes... Thank you again!


one list is still one argument. But i know what you are trying to say, and you are right :slight_smile: well done :slight_smile:

no problemo


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