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 68inches tall. Add a sublist to the end of theheights` list that represents Vik and his height.”
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 ??
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()?
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.