The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
one question:
I want to write a code in this exercise to get the averages of each student whit the “get_average()” function and put them in a list like this:
class_list = [lloyd, alice, tyler]
results = [80.55, 90.15, 79.9]
I wrote the below code, but I get this answer “None, None, None”
for student in class_list:
results = [ ]
result = get_average(student)
print results.append(result)
I am stuck. And now I am worried programming is not for me. Because with this lesson is when it get’s hard, so far our hand was held as it said in the text.
Can someone help me without providing the solution? In a way that I learn. For now I am stuck.
I don’t understand this:
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 .
There is no student item in class_list because the example only told me to to write the function with it as an argument.
This is my code.
def get_class_average(class_list):
results = []
for get_average(student) in class_list:
results.append()
return average(results)
The class_list is the global object, students which contains references to three dictionaries. In a dictionary, a key-value pair is known as an item, but in this instance, item is referring to each referenced object, in turn. That would make it an element but we get the idea.
There is when we pass the students object as an argument of the call to get_class_average; as in,
print(get_class_average(students))
You should have a students object in with your global data…
students = [lloyd, alice, tyler]
That line would, one thinks raise an exception.
for student in class_list:
results.append(get_average(student))
I think we do create it at some point earlier, but it may not be carrying over. Just insert that object underneath the three dictionaries so it is grouped with the data.
For each student item in the class_list , calculate get_average(student) and then call results.append() with that result.
Okay, I understand the bold one. It instructs me to write “for student in class_list:”
But then I do not undersatand how to write the rest of the code. How to calculate?
I don’t quite understand what is happening here. Could you explain?
What does results.append does?
How can there be a “results” when that is not a variable that has been defined earlier? Calling implies a function…how can we call a function that has not been defined?
This did in fact work for me, but it did NOT return your below result. It actually returned only the letter “B”. I’m also curious as to why ‘n’ is used instead of student.