Student becomes the teacher: for the record, (I dont understand the error in question, and its a long one so its posted in the thread)


Below this line, add a link to the EXACT exercise that you are stuck at.

Here is my code:

lloyd = {“name”: [“Lloyd”],
“homework”: [100.0, 92.0, 98.0, 100.0],
“quizzes”: [82.0, 83.0, 91.0],
“tests”: [89.0, 97.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 key in students:
print lloyd, alice, tyler

I get the editor to print out what I want, but it doesnt look neat at all. I would like it to print out the information more neatly, but I have forgotten how to go about it. If anyone, with more experience than myself, could tell me how to print out Lloyds information first(so that it looks neat), alice second and tyler last, it would be greatly appreciated. As it is now, it prints out everything without any spaces between the info.

Anyhow, onto my next problem; my error message. This is the error I get after running the code, it does however not pop up imediately but rather takes a minute before it appears:

Traceback (most recent call last):
File “/var/codecademy/codex/runners/python/”, line 152, in
File “/var/codecademy/codex/runners/python/”, line 44, in start
command = self.readline().strip()
File “/var/codecademy/codex/runners/python/”, line 14, in readline
line = sys.stdin.readline()
File “/var/codecademy/codex/runners/python/”, line 47, in
signal.signal(signal.SIGALRM, lambda x, y: _raise(ExecTimeoutException(msg)))
File “/var/codecademy/codex/runners/python/”, line 12, in _raise
raise exception
runner_utils.ExecTimeoutException: Program took too long to terminate.

I dont understand what it meeans or why it appears constantly. I also have to refresh my browser after this error message to be able to run any more code. Hope it helps, as I have tried to be as succinct as possible.


I am in different lesson, but i have exact same problem as you described!

The name property for each dictionary should be a string, not a list.

'name': 'Lloyd'

Since you are iterating a list of dictionaries,

for student in students:
    print student

There won’t be any particular order to the dictionaries, but the list will print in order.

If you wish to pretty print with some order, then it will take a little extra code.

>>> for student in students:
    print ('\nName: {}'.format(student['name']))
    for grade_type in ['homework', 'quizzes', 'tests']:
        print ('{}: {}'.format(grade_type,student[grade_type]))


Name: Lloyd
homework: [100.0, 92.0, 98.0, 100.0]
quizzes: [82.0, 83.0, 91.0]
tests: [89.0, 97.0]

Name: Alice
homework: [100.0, 92.0, 98.0, 100.0]
quizzes: [82.0, 83.0, 91.0]
tests: [89.0, 97.0]

Name: Tyler
homework: [0.0, 87.0, 75.0, 22.0]
quizzes: [0.0, 75.0, 78.0]
tests: [100.0, 100.0]

Oh, thanks! I originally had the names as strings but since I encountered errors I just tested what would happen if I made them a list instead. I’m not very experienced or skilled in programming so I often just use the limited skills I have and just try out different things to see what happens. However, as having the names as lists didnt fix the issue I have no Idea how or why it is occuring. Thanks for helping me print the data in a nicer looking way!


1 Like

Did you sort out the issue?

The second error is not caused by our code, but an issue in the interface. If it continues, bring it up so we can refer it to the dev team.

I’m not encountering the issue at the moment so it might be something on my end, but if it does pop up again I will make sure to report it.


1 Like