# Student Becomes Teacher

#1

I keep getting the message:
Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected

Below is my code for this step.

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

#2

It would be better if you posted your entire program preformatted in a reply. The way to do that is to go to your program code and click the cursor in the code text somewhere, press CTRL and A to select all your code's text, then CTRL and C to copy it, then paste that in a reply to this by pressing CTRL and V. Once you have it pasted in the reply box, highlight it again using the mouse, then click the Preformatted Text button above here: </> This will convert your code into a scrollable window within the reply box, and make it easier to see and debug.

#3
``````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]
for student in students:
def average(numbers):
total = float(sum(numbers))
def average(numbers):
total = sum(numbers)
total = float(total)
total = total / len(numbers)

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

if score == int or float:
if score >= 90:
return "A"
elif score < 90 and score >= 80:
return "B"
elif score < 80 and score >= 70:
return "C"
elif score < 70 and score >= 60:
return "D"
else:
return "F"
else:
return "Not a float or integer"

def get_class_average(students):
results = []
for student in students:
results.append(get_average(student))
return average(results)
students = [lloyd, alice, tyler]
indent preformatted text by 4 spaces``````

#4

Thank you. I reposted my code.
Can you take a look and see where I have made a mistake that causes me to get the message that the average score is incorrect?
Message: Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected

#5

@devsurfer93243

If your formatted code is exactly as your actual code there are a number of problems:
1/ After the lines:

students = [lloyd, alice, tyler]
you have for loop stepping through students,
then you define an average function twice
I would remove the for loop before your function definitions, and remove one of the average function definitions

After your last function definition return statement for get_class_average, you have the following lines:
students = [lloyd, alice, tyler]
indent preformatted text by 4 spaces

Remove these two lines and see what happens

#6

I was missing an indent at the bottom of the code that was preventing the code from performing properly, thank you.