8. Part of the Whole


So, i don't know where my error is.
This code:

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

gives me this error:
Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected.


a function ends the moment the moment a return keyword is reached (if i would get a euro every time i wrote that, i could go on a nice holiday now :stuck_out_tongue: )

so your function ends in the first iteration of the loop, which means it can't calculate the correct class average for a class of 2 more students, to calculate the correct class average for 2 of more students the loop needs to be able to make all iterations


God i could've seen that by myself.

Anyway, thanks for the fast reply!


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