# 9. how´s everyone doing?

#1

students = [lloyd, alice, tyler]
print get_class_average(students)
I´ve been trying to solve code,
what seems to be the problem?
Whe I try this one, it says:

Did you remember to print the average of the class? It looks like "83.8666666667" wasn't printed.

#2

Do you mind pasting your whole code? Might just be a "glitch" per say so refreshing might work but it could also be something in the other parts of your code. i don't see anything in just those three lines that would fail you

#3

Not at all mate.

here´s my whole code:

``````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) / 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"
if score >= 70:
return "C"
elif score >= 60:
return "D"
else:
return "F"

students = (lloyd, alice, tyler)
def get_class_average(students):
results = []
for student in students:
results.append(get_average(student))
return average(results)

students = [lloyd, alice, tyler]
print get_class_average(students)

#4

So this students list right here seems to be the problem. I don't believe it is necessary so get rid of it and that should fix your problem....

#5

I still don´t see the problem, sorry mate.
I deleted it, and nothing, same message comes out.

#6

Your good. Let me paste your whole code into my lesson and I will play with it for a minute

#7

Eurekaaaa!!! Don't ask me why though but your problem was that your spacing/indention was off. If you move back all three of those lines at the very end of your code it works.

Also, might just be style preference here but I changed this:

to this:

#8

Thank you very much, it worked

#9

Yeah I will try and do some research on the spacing though because even I would like an explanation on that one but I know python is very picky about spacing and indentions so it might not have read your print statements because their indention was off. No proof of that but it is a hunch...

Anyhow, your welcome! Happy coding and congrats on finishing this! You got functions I believe up next!

#10

Yes, functions. Learning is not easy but totally rewarding, specially when you can count on such helpful friends. Thanks

#11

You know how javascript uses curly braces, { }, to signal what's inside of a function, loop, if/else statement, etc.? Well python's design choice was to use indentation to signal that. In Java, JavaScript, etc. indentation doesn't matter, but in python, it's necessary.
I hope this makes sense

The reason it was a problem was because those print statements were considered part of the function `get_class_average()`, so no call was made to them because you have to call things from outisde of the function.

@bibleman13 good work.

#12

Ok that is good to know! And it makes sense oh Wise Teacher Kyleaw! xD

#13

Yeah aahaha, it's a different thing, but it's actually pretty cool. It's annoying that the lessons don't teach about it really though.

i wish

#14

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