## danmei 3 years ago Can someone tell me why the output on this is 4 times? Lloyd = { "name":"Lloyd", "homework": [90,97,75,92], "quizzes": [ 88,40,94], "tests": [75,90] } Tyler = { "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } student = ["Lloyd", "Alice", "Tyler"] def average(student): for person in student: ave = float(sum(student["homework"]))/len(student["homework"]) print ave average(Lloyd)

1. lh4219

The print avg should be directly under the for

2. danmei

thanks, that did it!

3. MicroBot

actually your code is strange...what are you supposed to do? cause like that it gives only the average of the asked student but you have code u dont need at all.

4. MicroBot

Lloyd = { "name":"Lloyd", "homework": [90,97,75,92], "quizzes": [ 88,40,94], "tests": [75,90] } Tyler = { "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } Alice={ "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } def average(student): ave = float(sum(student["homework"]))/len(student["homework"]) print ave average(Lloyd) this does the same thing. i set Alice as you didnt have her .