Increment a single element in a 2-dimensional list

Viewed 33

In my code below, I have a 2-dimensional list of school subjects with their specified grades. I attempted to update the value for the subject (visual arts) from 93 to 98. I specified the value's index location and then used the assignment operator to update the value. The result looked to have worked but I would appreciate it if someone could confirm. Is the below solution correct or is there is a more efficient manner to handle this?

subjects = ["physics", "calculus", "poetry", "history"]
grades = [98, 97, 85, 88]
gradebook = [["physics", 98], ["calculus", 97], ["poetry", 85], ["history", 88]]

gradebook.append(["computer science", 100])

gradebook.append(["visual arts", 93])
gradebook[5][1] = 98

print(gradebook[5][1])
0 Answers
Related