FAQ: Learn Python: Student Becomes the Teacher - For the Record

This community-built FAQ covers the “For the Record” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise For the Record:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Other FAQs

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 (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

4 posts were split to a new topic: Why Doesn’t This Code Pass the Test?

A post was split to a new topic: Students become teachers - for the record

Why can’t I do:

for student in students, print student [“name”, “homework”, “quizzes”, “tests”]

Instead of:

for student in students:
print student[“name”]
print student[“homework”]
print student[“quizzes”]
print student[“tests”]

??? Thank you!

2 Likes

I’m using this:

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:
  print student["name”]
  print student["homework”]
  print student["quizzes”]
  print student["tests”]

and outputs this:
Traceback (most recent call last):
File “/var/codecademy/codex/runners/python/cli_runner.py”, line 152, in
CLIRunner().start()
File “/var/codecademy/codex/runners/python/base_runner.py”, line 46, in start
self.handle_command(command, code)
File “/var/codecademy/codex/runners/python/cli_runner.py”, line 76, in handle_command
res = self.execute(code, self.run_globals)
File “/var/codecademy/codex/runners/python/cli_runner.py”, line 118, in execute
runner_io.stderr.write(’’.join(list))
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 23: ordinal not in range(128)

What does this mean?

this means you use a wrong character here:

print student["name”]

the quotation mark you use to close the string, isn’t right. see how its slightly tilted?

Now I see. Thanks!

So:

print student["name"]

prints the correct answer, right?

yes, but looking at your code, that wasn’t the only odd quotation mark

I see. Thanks for helping!

This exercise was really bugging me. I saw the list students = [lloyd, alice, tyler] and figured I should be using it with my dictionaries somehow. I also noticed that the answer was calling for a some for loops. Initially I couldn’t figure out how to work them all together so I came up with the following answer:

for x in tyler:
  print(x)
  print(tyler[x])
for x in alice:
  print(x)
  print(alice[x])
for x in lloyd:
  print(x)
  print(lloyd[x])

Seeing the same kind of action happen over and over indicated to me that there was a for loop that I wasn’t using. What I ended up doing was nesting two for loops together.

for dictionary in students:
    for item in dictionary:
        print(item)
        print(dictionary[item])

This worked out pretty well and made use of the list and the dictionary working together. I hope this helps anyone else who was bothered by their being a list and a dictionary together but was having trouble getting them to work together.

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:
print students [0:3]