Lesson 1: Error "The name key does not have the value "Lloyd..."


#1

I'm getting the error "The name key does not have the value "Lloyd" in your lloyd dictionary." My code is:

lloyd = {
    'name': "Lloyd", 
    "homework": [], 
    "quizzes": [], 
    "tests": []
}

print lloyd
print lloyd["name"]

You can see that I added a print line to check what the key was returning, and it did return "Lloyd" in the console. But for some reason, I'm still getting the error.

Just to check for subtle typos/errors, I copied and pasted the solution code from here: http://discuss.codecademy.com/t/student-becomes-teacher-lesson-one/20975. That also returns the same error.

No misspelling, no capitalization errors, no missing commas, no square brackets where they shouldn't be...returns the correct value in the console....I'm stuck as to why the teaching module is still finding an error.


#2

Hi @elkurten,

I remember someone having a similar error, check your curly brackets around the 'alice dictionary' or the 'tyler dictionary' because some of the following lines may cause an error with the lloyd dictionary.


#3

I have the same problem, I run it on spyder and it does return "Lloyd", so I-m guessing there's a bug on codeacademy or something


#4

I just got it...

i had [] on the value, fool of me.


#5

It wasn't curly brackets, but it did involve adding the other dictionaries to the code. Just learned how copying works in Python.


#6

Nice for you, but what exactly is the solution.
My code looks like this (correct, I would say)

lloyd = {
    "name": "Lloyd",
    "homework": [],
    "quizzes": [],
    "tests": [],
}

alice = {
    "name": "Alice",
    "homework": [],
    "quizzes": [],
    "tests": []
}

tyler = {
    "name": "Tyler",
    "homework": [],
    "quizzes": [],
    "tests": []
}

Sorry, found the solution. The code above works.


#7

this is the ■■■■. perfectly coded.

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)
    return total
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    
    return 0.1 * homework + 0.3 * quizzes + 0.6 * tests 
    
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"


students = [lloyd, alice, tyler]

def get_class_average(students):
    results = []
    for item in students:
        results.append(get_average(item))
    return average(results)
    
print get_class_average(students)
print get_letter_grade(get_class_average(students))