How did this pass?


So my code passed the exercise without printing anything. When I try my code in PyCharm it gives me an invalid syntax error on the last line of code. What gives? I'm really trying to wrap my head around this assuming I did something wrong. Or is it just the game making a mistake?

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 = (float(sum(numbers)))/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"
    elif score >= 70:
        return "C"
    elif score >= 60:
        return "D"
        return "F"
    print get_letter_grade(get_average(lloyd))


Move your print statement back 2 spaces and you will see a letter grade! :smiley: Sorry I am at lost for words for why it passed but I will look into it for ya if you want more info.


I tried that and still get the same invalid syntax error.


Ok well I have never used PyCharm but more than likely they are on Python 3. Codecademy is on Python 2 until they update it hopefully later on this summer! So there might be some error that doesn't exist in Python 2 that does exist in Python 3 because things have changed in how stuff is structured etc.


Yeah, that makes complete sense. I didn't realize Codeacadamy wasn't on Python 3. Is it still worth going through the whole course here then?


oh yeah. I mean its not like Python 2 is completely obsolete lol You will still learn a lot of Python's basic and advanced functions and such. Now, I haven't looked to in depth with the differences between Python 2 and Python 3 but I am sure a quick google search can bring something up for that.... And if I had to guess there will be some big differences but the core language should be the same.

Results from Quick Google Search:

These at a quick glance seemed like reasonable resources but take them with a grain of salt as always. I will try and find something more official. Here is the official Python website: and apparently the link from that website for this type of question is the wiki python link above so that should be solid then I would assume if they are using it.


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