# FAQ: Creating and Modifying a List in Python - List of Lists

This community-built FAQ covers the “List of Lists” exercise from the lesson “Creating and Modifying a List in Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

on this lesson code editor is not loading, I’ve tried multiple refreshes on the page, clearing my cache and so on, but still nothing, please fix!

On previous lessons, we were told we could use .append method to add to list.
Here we cannot use append() and the solution shows a solution of manually adding to the 2D list?

“A new student named `"Vik"as joined our class. Vik is `68`inches tall. Add a sublist to the end of the`heights` list that represents Vik and his height.”

Is there a better way to do this?

1 Like

nevermind figured out what the problem was

can be done with the
heights.append([“Vik”,68])

1 Like

I have a question. if I have this bidimensional list
heights = [[“Jenny”, 61], [“Alexus”, 70], [“Sam”, 67], [“Grace”, 64]]

if I write this code
print(heights[0])
the print in the command line gives this answer
[“Jenny”, 61]
how I can take from the first element of the bidimensional list only the int variable ??

If I save the first element in a variable how in this case

data_Jenny=heights[0]

data_Jenny becames a list not a bidimensional list and if I write this row

print(data_Jenny[1]) I print only the height of Jenny

this is correct but I don’t know if there are some other method

I’d like to know if there is a method to add to a 2d list without creating a new list and adding it to the first list. Is there a way to do it with .append() or .extend()?

[py]

[/py]
heights = [[“Jenny”, 61], [“Alexus”, 70], [“Sam”, 67], [“Grace”, 64]]

heights.append([“Vik”, 68])

ages =

#Neither method works to add to 2d list

ages.extend([“Arron”, 15], [“Dhruti”, 16])

ages.append([“Arron”, 15], [“Dhruti”, 16])

#TypeError: extend() takes exactly one argument (2 given)

print(ages)

Got it! I was missing a set of brackets.

ages.extend([[“Aaron”, 15], [“Dhruti”, 16]])

I think the easiest way to do is to create a variable first then append the new_variable. print the heights.

#Create a list
Vik = [“Vik”, 68]

heights.append(Vik)
print(heights)

Can anyone explain why am I getting this message?

I am not a subscriber, so I can’t access the exercise. But, are you sure that the `heights` list in your screenshot is correct? If I am not mistaken, that list is in the explanatory text of the exercise BUT the `heights` list for the actual exercise is different. Looking at the earlier posts, it seems that the `heights` list for the actual exercise is `[["Jenny", 61], ["Alexus", 70], ["Sam", 67], ["Grace", 64]]`. Did you by any chance delete the original list and replace it with the list from the explanation?

I would suggest resetting the exercise. From the drop-down menu, you can select “Get Unstuck > Reset Exercise” and then click the link for “Reset Exercise”. This should recover the original list. You can then append the student specified in Step 1 to this list.

1 Like

ok got it, I thought I had to use the names in the example. Thank you!

1 Like