Need help with appending two-dimensional list in python

Appending two-dimensional list

Hi,

Please help me with the following code. I am supposed to add a list to a 2-D list. Although I have added the list, the output is coming like this:
gradebook = [(‘physics’, 98), (‘calculus’, 97), (‘poetry’, 85), (‘history’, 88), ‘computer science’, 100]

Don’t know why ‘computer science’, 100 (this is the list which I am supposed to add to the gradebook) are not in brackets just like rest of the items.

Please tell me the reason why is it coming so and how to solve it? Thanks

Here’s the link to the task
https://www.codecademy.com/courses/learn-python-3/projects/python-gradebook

Your code below:

subjects =
subjects.append(“physics”)
subjects.append(“calculus”)
subjects.append(“poetry”)
subjects.append(“history”)
print(subjects)
grades = [98,97,85,88]
print(grades)
gradebook = zip(subjects, grades)
gradebook_1 = list(gradebook)
new_value = [‘computer science’, 100]
for i in new_value:
gradebook_1.append(i)
print(gradebook_1)

Hi there, in Python, 2D lists look like this →

For example,

# A 2D list of names and hobbies
class_name_hobbies = [["Jenny", "Breakdancing"], 
["Alexus", "Photography"], ["Grace", "Soccer"]]

You can consider making it gradebook = [["Physics", 98], ["Calculus", 97], ["Poetry", 85], ["History", 88]] saved into a variable. After that, you may use .append( ) to append a list into gradebook variable. For example, gradebook.append(["Computer Science", 100]).

Note that:

The above what I have quoted should be in a list not in bracket form.

Thank you for your help. Can you also tell me how to turn gradebook list into this [[“Physics”, 98], [“Calculus”, 97], [“Poetry”, 85], [“History”, 88]]` ?

I have shown an example here, also there is hint here →

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