8. Part of the Whole


#1

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

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

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


#2

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


#3

God i could've seen that by myself.

Anyway, thanks for the fast reply!


#4

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