Python GradeBook Project

Hello! A quick question, I recently completed the Python Gradebook Project with the following code:

last_semester_gradebook = [(“politics”, 80), (“latin”, 96), (“dance”, 97), (“architecture”, 65)]

subjects =[‘physics’,‘calculus’,‘poetry’,‘history’]

subjects.append(‘computer science’)

grades = [98, 97, 85, 88]

grades.append(100)

gradebook = list(zip(subjects, grades))

gradebook.append(‘visual arts’, 93)

print(list(gradebook))

full_gradebook = last_semester_gradebook + gradebook

I received the following error: Traceback (most recent call last):
File “script.py”, line 13, in
gradebook.append(‘visual arts’, 93)
TypeError: append() takes exactly one argument (2 given)

I figured out that gradebook.append(‘visual arts’, 93) needs to have another set of parenthesizes and it should look like: gradebook.append((‘visual arts’, 93)). I watched the solutions video, but it’s still not clear to me why we need to use a double set of parentheses rather than a single set.

Thank you in advance!

As the error indicates, .append() only takes one argument. Here, the extra parentheses help the computer know that you are providing one argument (in this case, one tuple of ('visual arts', 93)) rather than two separate arguments of 'visual arts' and 93.

1 Like

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