Gradebook

Not sure why it says value isnt in list

Traceback (most recent call last):
File “script.py”, line 12, in
gradebook.remove( 85 )
ValueError: list.remove(x): x not in list

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 = [[“physics”, 98], [“calculus”, 97], [“poetry”, 85], [“history”, 88]]

print(gradebook)

gradebook.append([“computer science”, 100])

gradebook.append([“visual arts”, 98])

gradebook.remove(85)

gradebook.append([“poetry”, “Pass”])

full_gradebook = [[last_semester_gradebook] + [gradebook]]

print(full_gradebook)

gradebook is a list of lists.
85 is not in gradebook, but 85 is in a list that’s in gradebook

The list containing 85 is ["poetry", 85]
And if you want to remove this list from gradebook,
you would do
gradebook.remove( ["poetry", 85] )

2 Likes

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