Gradebook project in codcademy- python 3

Hello,

I’d appreciate your advice in the last part of the gradebook project (from point 7 on the instructions).
Your help is very valuable!

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)

subjects.append(‘computer science’)
grades.append(100)
subjects.append(‘visual arts’)
grades.append(98)
gradebook = subjects + grades
print(gradebook)

full_gradebook = gradebook + last_semester_gradebook
print(full_gradebook)
Tank you

What code did you write for that question?
“Our instructor just told us they made a mistake grading and are rewarding an extra 5 points for our visual arts class.
Access the index of the grade for your visual arts class and modify it to be 5 points greater.”

So, you have to access both the indicies for the last inner and outer list. What are those indicies?

[['Physics', 98], ['Calculus', 97], ['Poetry', 85], ['History', 88], ['Computer Science', 100], ['Visual Arts', 93]]

gradebook[?][?] = 98
print(gradebook)
2 Likes

Thank you for the reply, Lisa.

Here is my code for the whole project. I am not entirely sure if it is right.

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’, 93])
gradebook[-1].append(98)

gradebook = subjects + grades
print(gradebook)

full_gradebook = gradebook + last_semester_gradebook
print(full_gradebook)

You’re close.

this is the part:

gradebook.append(['visual arts', 93])
gradebook[-1].append(98)
print(gradebook)

It’s good to add print() statements to see what your code looks like. That bit above just adds 98 to the end:
[['Physics', 98], ['Calculus', 97], ['Poetry', 85], ['History', 88], ['computer science', 100], ['visual arts', 93, 98]]

You need to also access ‘visual arts’. What is the index for that subject, or, how would you access it?
See:
https://www.codecademy.com/courses/learn-python-3/lessons/create-python-list/exercises/modifying-2-d-lists

gradebook[-1][-1] = 98
print(gradebook)
1 Like