How to fix this


The code below works and prints out the result in the console but it comes with an error message
"Oops, try again. One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade
can anyone pls suggest a solution

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 = 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"
    elif score >= 70:
        return "C"
    elif score >= 60:
        return "D"
        return "F"
print get_letter_grade(get_average(lloyd))
#print get_letter_grade(get_average(alice))
#print get_letter_grade(get_average(tyler))

def get_class_average(students):
    results = []
    for student in students:
    return average(results)

student_list = [lloyd, alice, tyler]
print get_class_average(student_list) 
print get_letter_grade(get_class_average(student_list))


Your error message complains about one of six names, check those six names, for example by printing them


The program expected me to use "students" as the name of the list, instead I used "student_list".
So when I use this code it worked.

students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))


Many users who are completing Student Becomes the Teacher in the original Python track have encountered that same problem.

In Exercise 3: Put It Together, the instructions have the user create the list ...

students = [lloyd, alice, tyler]

That list carries over to Exercise 4: For the Record.

However, the list does not seem to carry over to the default code for Exercise 5: It's Okay to be Average.

For the next several exercises, the absence of that list might go unnoticed.

Then, in Exercise 9: How is Everybody Doing?, Codecademy's submission correctness test (SCT) checks for that list, and complains if it is not there.

I no longer recall whether this also happens in the new Learn Python version of Student Becomes the Teacher.

EDIT: November 28, 2016 - Yes, this does also happen in the new Learn Python version of Student Becomes the Teacher.


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