9. How is everybody doing? Error


#1

"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"

Here's my code:
I don't understand how something can be "broken" if I am getting some values in the console that seem to be correct :confused:
Thanks in advance for your help guys!

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)
    return float(total) / len(numbers)


def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return homework*.1 + quizzes*.3 + tests*.60

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"
        
        
def get_class_average(students):
    results = []
    for student in students:
        results.append(get_average(student))
    return average(results)
    
print get_class_average([lloyd, alice, tyler])
print get_letter_grade(get_class_average([lloyd, alice, tyler]))

#2

Try this:
students=[lloyd,alice,tyler]
print get_class_average(students)

Because it says in instruction to print out the result of calling get_class_average with your students list and your students should be [lloyd, alice, tyler].


#3

As with the comment above.

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


#4

I am also having this issue. I tried @cssmaster23105 cssmaster's code and it threw the same error. Also, the lesson does ask for the last line to be a variation of:
print get_letter_grade(get_class_average(students))
and not:
print get_letter_grade(students)
as they suggested.


#5

plssss i need the code ! HELPPP MEEEEE! i give up! i can't and i can't find the solution ! plss helpp mee i need finish!!


#6

Add the following syntax, assuming you're on step 9 and you've passed the previous steps.

#define the list
students = [lloyd, alice, tyler]

#get the class average
print get_class_average(students)

#print the letter grade associated with the average from above
print get_letter_grade(get_class_average(students))

#7

yeah! i have this in my code ! but still dont work:

this is my 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]
}

def average(numbers):
total = sum(numbers)
return float(total) / len(numbers)

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
weighted = (homework * 0.1) + (quizzes * 0.3) + (tests * 0.6)
return weighted

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))
def get_class_average(students):
results = []
for student in students:
new_average = get_average(student)
results.append(get_average(student))
return average(results)

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


#8

Try this, it's my exact syntax.

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):
    return float(average(student["homework"]) * 0.1) + \
    float(average(student["quizzes"]) * 0.3) + \
    float(average(student["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))

def get_class_average(students):
    results = []
    for each in students:
        results.append(get_average(each))
    return average(results)
    
students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))

#9

OMG damnt... nothing!...the code don't work...


#10

Really? I literally just hit accept and it passed...


#11

really let me show you!!!
hahha i can't belive...
this never happend me before!!


#12

:confused: Sorry friend. Not sure why it isn't working for you when it does for me.


#13

omg bro! thanks so much! i think maybe is ■■■■■■■ problem with the console or the navigator...idk...
thanks for your time my friend!
i will make a ■■■■■■■ post to codecademy.. :rage:


How is everybody doing! Moderators Help pLease!
#14

@ritterc 's code does work! I tried it and found that if there were white spaces before code, it won't work, so try another time, you'll pass


#15

an alternate code that I used to pass because I seem to get a lot of errors when my code looks like some of the recommended codes is:

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]
}
students = [lloyd, alice, tyler]

def average(numbers):
total = sum(numbers)
new_total = float(total)
return new_total / len(numbers)
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
sum = homework * .1 + quizzes * .3 + tests * .6
return sum
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 score.get_average(students)

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


just make to indent properly


#16

It looks different than the strange behavior everyone else is having but I was having lots of trouble with this lesson too and it seemed to take me forever to figure out:
I had:
students = ["lloyd", "alice", "tyler"]

This is wrong; there should not be quotes around the student list; it should be:
students = [lloyd, alice, tyler]

hope that helps someone