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 - += 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
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
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
python 2D list appends the element to every list in it - Stack Overflow
i was doing an assignment using Python and i had to use a 2D list with a specific size. ... Try to think of lists as x=[]; lists = [x,x,x,x,x,x,x,x,x,x]. ... This is because when you declared lists = [[]]*10, you are instantiating a list of sublists that all point to the same list. Thus, when you append ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Delft Stack
delftstack.com โ€บ "delft stack" โ€บ "howto" โ€บ "python how-to's" โ€บ "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
Step 2 We access each sub-list and call append on it. This appends to the inner lists. Step 3 We display the element at indexes 0, 0 and this value is 1. With the print() method we can display the entire list contents. Step 4 This loop can iterate rows and columns in the 2D list.
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ watch
How Does Append Work With 2d Lists In Python - YouTube
In this python tutorial we are talking about lists in python! Specifically, we are answering the question of how does append work with 2d lists in python! Le...
Published: January 4, 2023
๐ŸŒ
IQCode
iqcode.com โ€บ code โ€บ python โ€บ python-2d-array-append
python 2d array append Code Example
temp_list = [[], [], [], []] temp_list[0].append("a1") temp_list[1].append("a2") temp_list[2].append("a3") tem...
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ tutorials โ€บ python 2d lists: create, index, copy, flatten, and loop
Python 2d List: From Basic to Advance
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 ...
๐ŸŒ
Thedeveloperblog
thedeveloperblog.com โ€บ 2d-list-python
Python 2D List Examples
Append: We first create an empty list with the empty square brackets. Then we call the append method and add two empty lists.
๐ŸŒ
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.
๐ŸŒ
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()])
๐ŸŒ
Python Forum
python-forum.io โ€บ thread-30401.html
Append 2d empty lists
October 19, 2020 - Hi there! I wanted to store my functions result in a 2d list. The function returns 5 values and has to run 100 times in a for loop. I tried to initiate a storage list by ding this: list1 = [[]]*5which returns list1 = [[], [], [], [], []] However, w...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 47478587 โ€บ python-2d-list-appends-the-element-to-every-list-in-it
python 2D list appends the element to every list in it - Stack Overflow
i was doing an assignment using Python and i had to use a 2D list with a specific size. ... Try to think of lists as x=[]; lists = [x,x,x,x,x,x,x,x,x,x]. ... This is because when you declared lists = [[]]*10, you are instantiating a list of sublists that all point to the same list. Thus, when you append to the first item (or any item for that matter), it changes the original list, so all the lists that point to that also appear to change.
๐ŸŒ
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โ€ฆ