```
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=float(sum(numbers))
return float(sum(numbers))/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"
def get_class_average(students):
results[]
get_average(student).results.append()
Instructions:
Define a function called get_class_average that has one argument students. You can expect students to be a list containing your three students.
First, make an empty list called results.
For each student item in the class list, calculate get_average(student) and then call results.append() with that result.
Finally, return the result of calling average() with results.
i´ve tried many ways but i can´t get it
```

# Im stuck :(

**maverb**#1

**gargol12**#2

Seems like you need a "for" loop to iterate through that list

This should work:

```
for item in students:
""" calculate get_average(student) and then call results.append() with that result.
Finally, return the result of calling average() with results."""
```

Also try to change this:

to this:

`results = []`

Hope it helps!

**maverb**#3

def get_class_average(students):

```
for item in students:
results.append(get_average(student))
results=[]
```

one of the many options i typed, nothing works

**gargol12**#4

This should work:

```
for student in students:
results=[]
results.append(get_average(student))
return results
```

Try to review the main concepts of for loops in python

**gargol12**#6

my bad, this should work:

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

'results' needs to be out of the 'for' loop so it doesn't reinicialize avery time the loop runs, also 'return' need to be out to return the list of results when the loop ends.

**bibleman13**#7

And just a small critique, Step 4 says, "Finally, return the result of calling average() with results." You need the average of the results returned not just the results

`return average(results)`

**gargol12**#8

I just missed that, thank you for the clarification.

I edited my answer so it returns the average now ^^

**bibleman13**#9

No problem! Sorry I would just like it but I am out of likes for the next 22 hours haha

**maverb**#10

i hava a question then, the for loop has as his general form:

for variable in list name

In this excersise we´re typing :

for student in students, student is an argument for the get_average() function and students is an argument for the get_class_average() function-------> so i don´t get the relation we´re typing between student and students in the for loop

**gargol12**#11

It's just a name we give in this case, because "**students**"(plural) it's a list of students so it's natural to refer to a member of that list as a "**student**"(singular).

**maverb**#12

would you help me with the next excersise?

Finally, print out the result of calling get_class_average with your students list. Your students should be [lloyd, alice, tyler].

Then, print the result of get_letter_grade for the class's average.

**system**#15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.