Lists, GradeBook - Attribute Error

last_semester_gradebook = [["politics", 80], ["latin", 96], ["dance", 97], ["architecture", 65]]

# Your code below: 
subjects = ["physics", "calculus", "poetry", "history"]
grades = [98, 97, 85, 88]
gradebook = [subjects[0], grades[0]], [subjects[1], grades[1], [subjects[2], grades[2]],
subjects[3], grades[3]]
print(gradebook)
gradebook.append("computer science", 100)

Why do I get this error when running the code above:

([‘physics’, 98], [‘calculus’, 97, [‘poetry’, 85], ‘history’, 88])
Traceback (most recent call last):
File “script.py”, line 9, in
gradebook.append(“computer science”, 100)
AttributeError: ‘tuple’ object has no attribute ‘append’

There are some missing square brackets in your gradebook list.

Also, when appending there can be only one argument.

['computer science', 100]
1 Like

Hi mtf, still I get the same error.

I found the bugs…

this is the correct code(square brackets missed):

gradebook = [[subjects[0], grades[0]], [subjects[1], grades[1]], [subjects[2], grades[2]],
[subjects[3], grades[3]]]

What you told me was another bug.
Everything’s ok now. Thx!

1 Like