You haven't created three different empty lists. You've created one empty list, and then created a new list with three references to that same empty list. To fix the problem use this code instead:

listy = [[] for i in range(3)]

Running your example code now gives the result you probably expected:

>>> listy = [[] for i in range(3)]
>>> listy[1] = [1,2]
>>> listy
[[], [1, 2], []]
>>> listy[1].append(3)
>>> listy
[[], [1, 2, 3], []]
>>> listy[2].append(1)
>>> listy
[[], [1, 2, 3], [1]]
Answer from Mark Byers on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › appending-to-2d-list-in-python
Appending to 2D List in Python - GeeksforGeeks
July 23, 2025 - This modifies the contents of the sublist while keeping the 2D structure intact. += operator allows you to extend a sublist with multiple elements in a concise manner. ... This is equivalent to using extend(). If we want to append multiple sublists dynamically list comprehension is a concise option.
Discussions

do you guys know how to add append an array in a 2d array?
my_list = [[1, 2, 3, 4, 5]] new_list = my_list * 5 print(new_list) Prints: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]] But be aware that this only creates multiple labels to the same [1, 2, 3, 4, 5] list object. Mutating any one of the inner lists mutates all of the inner lists as there is only one inner list object: new_list[0][0] += 40 print(new_list) print(my_list) # The original list object Prints: [[41, 2, 3, 4, 5], [41, 2, 3, 4, 5], [41, 2, 3, 4, 5], [41, 2, 3, 4, 5], [41, 2, 3, 4, 5]] [[41, 2, 3, 4, 5]] but you can reassign different objects within new_list: new_list[1] = [7,8,9] print(new_list) Prints: [[41, 2, 3, 4, 5], [7, 8, 9], [41, 2, 3, 4, 5], [41, 2, 3, 4, 5], [41, 2, 3, 4, 5]] If you actually want deep copies of the original inner list, you can use a list comprehension: my_list = [[1, 2, 3, 4, 5]] new_list = [my_list[0][:] for _ in range(5)] new_list[0][0] += 40 print(new_list) Prints: [[41, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]] More on reddit.com
🌐 r/learnpython
5
5
February 19, 2024
Python: Appending a 2D list to another 2D list - Stack Overflow
I am trying to append a 2D list to another 2D list as follows: list1 = [('a', '1'), ('b', '2'), ('c', '3')] list2 = [('d', '4'), ('e', '5'), ('f', '6')] If I append list1 to list2 should output: ... More on stackoverflow.com
🌐 stackoverflow.com
May 1, 2015
Python: Appending numerous 2D list to one 2D list - Stack Overflow
For the sake of simplicity I will just use two lists. So I have the following 2D lists: > > a = [[1,2,3], > > [1,2,3]] > > b = [[4,5,6], > > [4,5,6]] And if I append list a and b, I'm looking to obtain the following: More on stackoverflow.com
🌐 stackoverflow.com
Two dimensional array in python - Stack Overflow
What you're using here are not arrays, but lists (of lists). If you want multidimensional arrays in Python, you can use Numpy arrays. You'd need to know the shape in advance. ... You try to append to second element in array, but it does not exist. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "python tutorial: how-to guides for everyday python problems" › "how to append 2d array in python"
How to Append 2D Array in Python | Delft Stack
February 22, 2025 - Python’s built-in lists can represent 2D arrays as lists of lists. The simplest way to append values is using the append() method.
🌐
Reddit
reddit.com › r/learnpython › do you guys know how to add append an array in a 2d array?
r/learnpython on Reddit: do you guys know how to add append an array in a 2d array?
February 19, 2024 -

say i have array [[1,2,3,4,5]], how can i duplicate it 5 times to [[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]] ?

🌐
Dot Net Perls
dotnetperls.com › 2d-python
Python - 2D List Examples - Dot Net Perls
Programs often must model 2 dimensions, not just one. In a Python list we can place other lists: this creates a 2D representation of objects. We can access elements on each list with an index—we must specify the X and Y positions. To construct a 2D list, we can use append() or an initializer.
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
The list [0] * m is n times consructed as the new one, and no copying of references occurs. Say, a program takes on input two-dimensional array in the form of n rows, each of which contains m numbers separated by spaces. How do you force the program to read it? An example of how you can do it: ... # the first line of input is the number of rows of the array n = int(input()) a = [] for i in range(n): a.append([int(j) for j in input().split()])
Find elsewhere
🌐
Iditect
iditect.com › faq › python › appending-to-2d-lists-in-python.html
Appending to 2D lists in Python
In Python, you can append elements to a 2D list (a list of lists) using the append() method or list comprehension. A 2D list is essentially a list where each element is itself a list.
🌐
Mrgoff
mrgoff.com › py_lists
Python toolbox MrGoff.com
2D list access syntax rules: You ... are given as an integers · To append an additional list to our list of lists, we declare the identifier of the list and use dot notation to append as shown below....
🌐
Stack Overflow
stackoverflow.com › questions › 38064885 › python-multi-dimensional-lists-appending-one-2d-list-into-another-list
arrays - Python: multi-dimensional lists - appending one 2D list into another list - Stack Overflow
May 23, 2017 - If at some point down the line you realise that you want BigTable to have more lists in it, say a TableC or TableD. Just use the append function.
🌐
Python Pool
pythonpool.com › home › tutorials › python 2d lists: create, index, copy, flatten, and loop
Python 2D Lists: Create, Index, Copy, Flatten, and Loop
July 14, 2026 - Do not call a Python 2D list a matrix without describing its shape and element contract. Clear invariants make indexing and validation much easier. Copy safely: Shallow row copies, aliasing, list multiplication, and deep copies. When the number of rows will grow over time, start with an empty outer list and append a new row for each record.
🌐
Codecademy Forums
discuss.codecademy.com › computer science
#12 how am I suppose to add to the 2d list? - Computer Science - Codecademy Forums
April 11, 2023 - You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility When you ask a question, don’t forget to include a link to the exercis…
🌐
AskPython
askpython.com › python › two-dimensional-array-in-python
Two Dimensional Array in Python - AskPython
December 27, 2019 - size = int(input()) array_input ... ... Elements in a 2D array can be inserted using the insert() function specifying the index/position of the element to be inserted....
🌐
GeeksforGeeks
geeksforgeeks.org › python-using-2d-arrays-lists-the-right-way
Python | Using 2D arrays/lists the right way - GeeksforGeeks
The code then shows another approach using a nested list comprehension to create the 2D array arr. This method avoids aliasing by creating a new list for each row, resulting in a proper 2D array. ... # Python 3 program to demonstrate working # of method 1 and method 2.
Published: June 20, 2024