Append with 2d lists

I understand append for a normal list for example:
list = [“Fish”, “Chicken”]
list.append(“Meat”)

would add Meat to the end of the list, but is it different for 2d lists?

Depends on what operation you want to do.

lst = [["Fish", "Chicken"]]
lst.append("Meat")
#[["Fish”, “Chicken"], "Meat"]
lst = [["Fish", "Chicken"]]
lst.append(["Meat"])
#[[“Fish”, “Chicken”], ["Meat"]]
lst = [["Fish", "Chicken"]]
lst[0].append("Meat")
#[[“Fish”, “Chicken", "Meat"]]

et cetera.
Play around with it in a terminal to get a better idea.

1 Like