def get_class_average(students):

results = []

for student in students:

get_average(student)

results.append(get_average(student))

return average(results)

# Part the whole ... advice if needed

**papayabubble**#1

**carwars5**#3

My code is exactly the same as the one posted here, but it does not work.

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)

mean = total / len(numbers)

return mean

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"

print get_letter_grade(get_average(lloyd))

def get_class_average(students):

results = []

for student in students:

get_average(student)

results.append(get_average(student))

return average(results)

**james.rhea**#4

Can you please post the message you received?

Also, can you enclose your code in backticks so it is properly formatted?

```
```
^ These are backticks.
Put three backticks on the line before your code.
Put three more backticks on the line after your code.
```

**james.rhea**#5

@papayabubble: What answer runs properly when I try it. Are you receiving an error message? If so, what does it say?

In terms of advice, I'd just ask: Why include this line? What does it do for you? Do you lose anything if you remove it from your code?

**papayabubble**#6

You need to use:

get_average(student)

because for a class average you need to add the averages from the different students. If you don't put it in your class average won't have any numbers to work on. Get it?

**james.rhea**#7

You're right the you need to do that at some point, but you do it twice.

Do you need the first instance?

**papayabubble**#8

You don't need it the first time but I put it in there to understand which step I'm at compared to the instructions.

**papayabubble**#9

Did you make sure your indentation was correct?

Or you can otherwise you could try it like this:

def get_class_average(students):

results = []

for student in students:

results.append(get_average(student))

return average(results)

I tried and it does not work!

The reply of the system is: ''Oops, try again. get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected''

**kakasy**#13

Write only the last method

I hope this will help you guys:

def get_class_average(students):

....results =[]

....for item in students:

........get_average(item)

........results.append(get_average(item))

....return average(results)

**aamirngr**#15

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)

return total/len(numbers)

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"

print get_letter_grade(get_average(lloyd))

def get_class_average(students):

results=[]

x=get_average(students[0])

y=get_average(students[1])

z=get_average(students[2])

results.append(x)

results.append(y)

results.append(z)

q=average(results)

return (x,y,z,q)

plz help me where i am goining wrong

error is Oops, try again. get_class_average([alice]) resulted in an error: list index out of range

**helene.tyler**#17

I got the same error message. Then I adjusted the indentation on the last line of code and it compiled properly.

**cloudslayer63023**#18

i've fix it try this 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 = float(sum(numbers))

result = total / float(len(numbers))

return result

# def get_average(lloyd,alice,tyler):

def get_average(student):

lloyd_homework=average(student['homework'])

lloyd_quizzes=average(student['quizzes'])

lloyd_tests=average(student['tests'])

lloyd_average_score=0.1*lloyd_homework+0.3*lloyd_quizzes\

+0.6*lloyd_tests

return lloyd_average_score

n = lloyd

print get_average(n)

def get_letter_grade(score):

if(score >= 90.0):

return "A"

elif score >= 80.0:

return "B"

elif score >= 70.0:

return "C"

elif score >= 60.0:

return "D"

else:

return "F"

print get_letter_grade(get_average(lloyd))

students = [lloyd,alice,tyler]

def get_class_average(students):

results = []

for item in students:

results.append(get_average(item))

`return average(results)`

**moysesgurgel**#19

Thank you for your kind cooperation. The key is to actually fix the indentation in the last line of code, stepping back "return".

**singingswitchman**#20

papayabubble, you are teaching yourself to write redundant code. This is messy and may cause issues on future assignments. You should comment out any redundant code that you write if you are going to leave it in to follow the instructions.