Oops, try again. getclass_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected_
This is the error when the return function is part of the for loop as shown in the code below. someone explain why the result behaves differently when the return average(results) is under the for loop function.
the code works well when the return average(results) is put in the same indentation block as the for loop.
explain why the change in the indentation produces a different result. Thanks
def get_class_average (students): results = for student in students: get_average(student) results.append(get_average(student)) return average(results)