8. Part of the Whole


#1

Hey! Can you help me with this one? What is wrong?

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


#2

Hi @kelsner ,

Because the code that you posted is not formatted, it is difficult for other users to read and debug it. After code has been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. Alternatively, you can place three backquotes on the line before the code and three backquotes on the line after the code. This will enable us to see important details, such as the indentation and underscores. If you use the backquotes, your code will be color-coded, making it especially easy to read.

The problem might be that you indented the return statement incorrectly. If you indent it too much, it becomes part of the for loop. Your code should be indented as follows

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

#3

Yes! You are right, thank you and sorry for the incorrect format :wink:


#4

exactly what i need....thanks tho.


#5

Your code might help me thank you for your help!