Sending a letter, correct code, STILL ERROR!


#1



i am stuck @ "sending a letter" in section "student becomes a teacher".

Although the code seems to be very fine still it is showing the error:
Oops, try again. get_letter_grade seems to be missing.

can you tell me where i went wrong? (probably spacing or something)

NOTE: i have not copied the whole code here, only the code which is exclusive to sending the letter" has been copied.

https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/3?curriculum_id=4f89dab3d788890003000096


 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"   
            
    get_letter_grade(get_average(lloyd))

#2

So I pasted your code into mine and the problem was that your def was spaced over one space too much


#3

i didnt get it. there is only one space b/w def and get_letter_grade. and thats the only def used in all here. can you please elaborate.


#4

Ok then I believe you then and if that is the case then your code works fine! It passed in my lesson. Try refreshing browser? Of course this is assuming all your other code is correct.


#5

You know that you havent put in a "print" in front of your "get_letter_grade(get_average(lloyd))"?


#7

Here is the entire code (which isnt working i.e. showing error not in the the print screen but otherwise in the red box that comes after you "save and submit a 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)
    total = float(total) / len(numbers)    
    return total

def get_average(student):
    suma = 0
    for key in student:
        if key == "homework":
            suma += average(student["homework"]) * .1
        elif key == "quizzes":
            suma += average(student["quizzes"]) * .3
        elif key == "tests":
            suma += average(student["tests"]) * .6
    return suma
    
    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))

#8

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