Student becomes the teacher: TypeError: list indices must be integers, not str


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/4?curriculum_id=4f89dab3d788890003000096

<In what way does your code behave incorrectly? Include ALL error messages.>
Traceback (most recent call last):
File “python”, line 50, in
File “python”, line 47, in get_class_average
File “python”, line 27, in get_average
TypeError: list indices must be integers, not str

<What do you expect to happen instead?>
The averages for each student to be calculated and to be appended to the results[] list, then to return results[], and print results.

```
def get_class_average(students):
    results=[]
    for student in everyone:
        results.append(get_average(everyone))
    return results
    
print(get_class_average(everyone))
<do not remove the three backticks above>

#2

where does everyone come from?

and

get_average(everyone)

what did you try here?

can you please post your full code here?


#3

I cant figure out how to paste code, so i used pastebin (if you dont want to click the link just tell me how to format code on here and ill c+p it) https://pastebin.com/srCsbr3v


#4

everyone is a list of the 3 dictionaries.

I called a function with (everyone) as the parameter


#5

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