Part of a whole


#1

def get_class_average(students):
    for a in students:
        results.append(get_average(a))
    return average(results)
        
print (get_letter_grade(get_average(lloyd)))

not sure what I am doing wrong


#2

step 2 of the instructions:

First, make an empty list called results

i don't see a results list?


#3

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

print (get_letter_grade(get_average(lloyd)))

it still isn't working


#4

does it make sense to declare results inside the for loop? If so, why?


#5

Anything that happens inside your loop is being repeated, so essentially you are telling the program to create an empty array for every iteration of the loop.

Create the results list outside the loop and your code should work!


#6

very true you have to make the results list


#8

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

It is saying in the error - Oops, try again. get_class_average([alice]) resulted in an error: 'dict' object has no attribute 'append'
I have tried using += instead of .append and it sill doesn't work. PLZ HELP


#9

you should have made a new topic

results is a dictionary in your case, why?


#10

I made a new topic with the new error message after I changed it to a list. I still have no clue what it wants me to do.


#12

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