Part of the Whole


#1

I BELIEVE I have this part of the code right, but I keep getting an error that "return is outside of function"

def get_class_average(students):
- results=[]
for student in students:
- get_average(student)
- results.append(get_average(student))
- students = ["lloyd","alice","tyler"]
return average(results)
print get_class_average(students)

ps (-) indicated indent


#2

Change the indenting and remove the students variable, like so;

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

The error message was quite literal - a return statement was used outside of a function. Only functions can be returned, so you needed to fix the indent to place the return statement inside the function.


#3

It's always something right in front of you, thanks so much!


#4

No problem! :slight_smile:


#5