How's everybody doing?


#1




File "python", line 45
students = [lloyd, alice, tyler]
^
SyntaxError: invalid syntax


why is this a syntax error? it worked earlier in the exercise and now suddenly it is a syntax error


students=[lloyd, alice, tyler]


#2

could be on the line above? Please post your full code


#3

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))
    return 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
    
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"
    else:
        return "F"

print get_letter_grade(get_average(lloyd)

students=[lloyd, alice, tyler]

def get_class_average(students):
    results=[]
    for student in students:
        avg=get_average(student)
        results.append(avg)
    return average(results)

print get_class_average(students)
print get_letter_grade(get_class_average(students))

#4

like i said, the problem is actually in the line above. Look at your parentheses


#5

is there another way to post my code other than copy/paste so the formatting is preserved?


#6

Did you see my reply about the suggested fix?

you could put it on repl.it or you could just simply use mark up:

To keep the formatting intact


#7

ok great that worked. so my follow-up question is how could i have known it was a problem on the line above? because it told me the problem was on this line. thats why i didnt check above.


#8

Because i am good :innocent:

Just kidding, because i know the once you start using parentheses you can put code over multiply lines:

print get_letter_grade(
    get_average(lloyd)
)

because this is valid (valid and recommend are two different things), but because you forgot ), python thought you still where busy with calling get_letter_grade.


#9

understood, :+1:thanks


#10