# Part of the whole ---string indices must be int not str

#1

https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/4?curriculum_id=4f89dab3d788890003000096

string indices must be int not str for get_class_average(asdf) function call

dont know why thats giving a problem

``````lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

# Add your function below!
def average(num):
total = sum(num)
average = float(total)/len(num)
return average

def get_average(stude):
home = average(stude["homework"])
qui = average(stude["quizzes"])
tes = average(stude["tests"])
return 0.10*home + 0.30*qui + 0.60*tes

def get_letter_grade(sc):
if(sc>89):
return "A"
elif(sc>79):
return "B"
elif(sc>69):
return "C"
elif(sc>59):
return "D"
else:
return "F"
get_letter_grade(get_average(lloyd))
asdf =  ['lloyd','alice','tyler']

def get_class_average(classs):
results = []
for student in classs :
results.append(get_average(student))

get_class_average(asdf)
#get_average("lloyd")``````

#2

yes u have more than on mistake.

asdf = [lloyd, alice, tyler]

this are defined variable and no strings!

#3

and you forgot the return statement

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

now it works

#4

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