AttributeError: 'zip' object has no attribute 'append'

My question is from the python gradebook project. " Your grade for visual arts just came in! You got a 93! After the creation of gradebook (but before you print it out), use append to add ("visual arts", 93) to gradebook " is task #6. Below is the code I have so far:

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”)
gradebook = zip(subjects, grades)
gradebook.append((“visual arts”, 93))

However, when I run it i get the error “AttributeError: ‘zip’ object has no attribute ‘append’”. I looked it up and apparently on python 3 the zip() turns it into a zip object and not a list, any ideas on how I can get this to work?


Nevermind I figured it out lol

gradebook = list(zip(subjects, grades)

Was able to fix it by turning it into a list, that way the append.() will work


@beta9196990428 Thanks for that info. I searched the web but couldn’t find append relating to zip.

Thank you so much for posting this. Was driving me nuts!

I didn’t understand why do we need to write this was…Could anybody please explain…Thanks

.append() is a list method, zip() does not return a list.

1 Like

Thank you, I was not able to figure it out :blush: sometimes I feel really useless.

Thank you. I wouldn’t be able to figure it out myself.

super helpful! thanks for posting