Append Error

I am working the gradebook exercise in python and have come accross an error I just can’t seem to resolve.

The directions ask for us to append a new grade and subject to the variable that has already been created by zipping the gradebook and grades together. See code below:

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

subjects = [“physics”, “calculus”, “poetry”, “history”]

grades = [98, 97, 85, 88]

subjects.append(“computer science”)
grades.append(100)

gradebook = zip(grades, subjects)

gradebook.append((93, “visual arts”))

print(list(gradebook))


However, I continue to draw the following error code each time I try and run the code:

Traceback (most recent call last):
File “script.py”, line 12, in
gradebook.append((93, “visual arts”))
AttributeError: ‘zip’ object has no attribute ‘append’

1 Like

found a solution, it deviates from the instructions but I turned the entire zip into a list.

the code as run below works as intended:

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

subjects = [“physics”, “calculus”, “poetry”, “history”]

grades = [98, 97, 85, 88]

subjects.append(“computer science”)
grades.append(100)

gradebook = list(zip(grades, subjects))

gradebook.append((“visual arts”, 93))

print(list(gradebook))

full_gradebook = list(gradebook) + last_semester_gradebook

print(full_gradebook)

@design9699039525,

Welcome to the forums!

If you look back over the exercise, Task 3 tells you to use zip and then save it as a list. Opening the hint, you can see how to do it:

Now looking back at the first code you posted here, you used zip(), not list(zip()):

However, in your second code you did it correctly…

… so there was actually no need to call list() on gradebook here:

It’s good that you figured out a way to achieve the goal of the exercise, I just wanted to clue you in on why it wasn’t working the first time.

Happy coding!

1 Like

Thanks for your response. I get it now.