# 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

#1

My code produces the following results:

B
83.8666666667
B
None

But also getting a validation error: 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 someone please point out why this happens?

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)
total = float(total)

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])

``return (homework * .1 + quizzes * .3 + tests * .6)``

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

class_average = get_class_average([lloyd, alice, tyler])
print class_average

#2

Never mind -- I realized that I didn't create a students list. Please ignore.

#3

Can you share your final code? I am still having problem with the right code.
I have created the students list as well, but still ... the same problem.

#4

Sure, here it 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)
total = float(total)

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])

``return (homework * .1 + quizzes * .3 + tests * .6)``

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

class_average = get_class_average(students)
print class_average

#5

Thanks! I was stumped by that message all day and then finally found the answer here. I added the students = [lloyd, alice, tyler] and everything is good.

#6

Hi, I'm still really stuck with this one, I have a list of students = [lloyd, alice, tyler] but I still get the same error - "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"

The console prints

80.55
None

Here 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]
}

student = [lloyd, alice, tyler]

def average(numbers):
total = sum(numbers)
total = float(total)
print total

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

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_average(lloyd)

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

``````students = [alice, lloyd, tyler]

print get_class_average(students)

#7

Try changing: def get_class_average(student):
to: def get_class_average(students):

and change: for student in student:
to: for student in students:

#8

That still doesn't work though.

If I also change results.append(get_average(students)) to results.append(get_average(student)) in the get_class_average function I get a new error - "Oops, try again. Did you remember to print the average of the class? It looks like "83.8666666667" wasn't printed."

Any other ideas?

#9

Hey, here is my code. Everything seems to be correct but I am getting the same error as mentioned in the topic of this discussion.

``````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]
}
class_list = [lloyd,alice,tyler]
def average(numbers):
total = sum(numbers)
total = float(total)
total /= len(numbers)

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

if score >= 90:
return "A"
elif 90 > score >= 80:
return "B"
elif 80 > score >= 70:
return "C"
elif 70 > score >= 60:
return "D"
else:
return "F"

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

average_class = get_class_average(class_list)
print average_class

#10

It is solved. I had defined students list as class_list

#15

And we will continue to remind members, without your help, if you please. Thank you.

This thread is over 11 months old. It is not necessary to necrotize a topic just to do our job. Please leave moderation to the moderators and find other ways to involve yourself. Thanks.

The above sequence of posts will be removed, presently.

#16