9.How is Everybody Doing?


Please help!

Add your function below!

def average(numbers):
total = float(sum(numbers))/len(numbers)
return total
def get_average(student):
return 0.1 * average(student["homework"])+\
0.3 * average(student["quizzes"])+ 0.6 * average(student["tests"])
def get_letter_grade(score):
if score>=90:
return "A"
elif score >=80:
return "B"
elif score >=70:
return "C"
elif score >=60:
return "D"
return "F"
print get_average(lloyd)
students = ["lloyd", "alice", "tyler"]
def get_class_average(students):
results = []
for student in students:
return average(results)
print get_class_average(students)
print get_letter_grade(get_class_average(students))

Traceback (most recent call last):
File "python", line 45, in
File "python", line 43, in get_class_average
File "python", line 26, in get_average
TypeError: string indices must be integers, not str

9/9 or earlier problem potentially... String issue

Hi, @methodwhiz16864 ,

Because your code is not formatted, it is difficult for other users to read and debug it. As code is being posted, you can format it by selecting it, and then by clicking the </> button above the editing area. This will enable us to see important details, such as the indentation and underscores.

The following may not be the only problem, but here you have created a list of strings, because you used quotes ...

students = ["lloyd", "alice", "tyler"]

That needs to be a list of the three dictionaries, as follows ...

students = [lloyd, alice, tyler]


Yes, thank you. Problem solved :relaxed:


how can i fix this?
File "python", line 3
SyntaxError: 'return' outside function