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 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
#12 how am I suppose to add to the 2d list?
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 exercise or project you’re dealing with! If you want to have the best chances ... More on discuss.codecademy.com
🌐 discuss.codecademy.com
0
0
April 11, 2023
🌐
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]] ?

🌐
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
🌐
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
🌐
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.
🌐
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 ...
🌐
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...
🌐
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…