# 8. Part of the Whole Error: Needs Integer and not String

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>
<In what way does your code behave incorrectly? Include ALL error messages.>
Oops, try again. get_class_average([alice]) resulted in an error: list indices must be integers, not str
<What do you expect to happen instead?>
Not sure how to make it print an integer and not string.

```python

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]
}

def average(numbers):
total = sum(numbers)
total = float(total)
return float(total) / len(numbers)

def get_average(student):
homework = average(student[âhomeworkâ]) * 0.1
quizzes = average(student[âquizzesâ]) * 0.3
tests = average(student[âtestsâ]) * 0.6
avefinal = ( homework + quizzes + tests)
return avefinal

if score >= 90:
return âAâ
elif score >=80:
return âBâ
elif score >= 70:
return âCâ
elif score >= 60:
return âDâ
else:
return âFâ
a = get_average(tyler)

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

``<do not remove the three backticks above>``

#2

@20dannyb,
What are you doing here

``````        get_average(student)
results.append(get_average(student))
``````

AND
then
as you have 1 list =results=
you are using that =list= as an argument
in a call on the get_average() functionâŚ!!!

#3

I too have the same problem - can anyone help?

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]
}

def average(numbers):
total = sum(numbers)

``````return float(total) / len(numbers)
``````

def get_average(student):
homework = average(student[âhomeworkâ])
quizzes = average(student[âquizzesâ])
tests = average(student[âtestsâ])
return homework * 0.1 + quizzes * 0.3 + tests * 0.6

if score >= 90:
return âAâ
elif score >= 80:
return âBâ
elif score >= 70:
return âCâ
elif score >= 60:
return âDâ
else:
return âFâ

``````get_letter_grade(get_average(lloyd))
``````

def get_class_average(students):
results =
for n in students:
results.append(get_average(students))
return average(results)

#4

@leonhard.wettengmx.n

Yes butâŚHow do I make it give me an integer and not a stringâŚ?

#5

@20dannyb,
Instead of calling the get_average() function
you should be calling the average() functionâŚ

#6

@leonhard.wettengmx.n

Okay, that solved my problem and passes #8. But it returns the exact same thing. Whether I call the get_average() function or the average() function, I get C printed in the console. How does that make sense? Itâs the same exact letter in the console but codecademy says one is wrong and one isnât. Explain please

#7

hey, not sure what your problem is but I see one error in your get_class_average definition
this:

should use n variable and not students as you are looping by n

#8

@20dannyb,
Please post the FULL code you are using nowâŚ
and mention the EXACT Oops or Error message you are gettingâŚ
and mention the course section we are now writing aboutâŚ