9. how´s everyone doing?


students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(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.


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


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]

# Add your function below!
def average(numbers):
    total = sum(numbers) 
    total = float(total) / len(numbers)    
    return total
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
def get_letter_grade(score):
    if score >= 90:
        return "A"
    elif score >=80:
        return "B"
    if score >= 70:
        return "C"
    elif score >= 60:
        return "D"
        return "F"

print get_letter_grade 
print get_letter_grade(lloyd)

students = (lloyd, alice, tyler)
def get_class_average(students):
    results = []
    for student in students:
    return average(results)
    students = [lloyd, alice, tyler]
    print get_class_average(students)
    print get_letter_grade(get_class_average(students))


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....


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


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


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:

print (get_letter_grade(get_average(lloyd)))


Thank you very much, it worked


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! :smiley:


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


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 :slight_smile:

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.


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


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 :wink:


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