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.
๐ŸŒ
Statistics Globe
statisticsglobe.com โ€บ home โ€บ python programming language for statistics & data science โ€บ append to 2d list in python (3 examples)
Extend 2D List in Python (3 Examples) | Append New Elements
April 5, 2023 - The code above is a concise way of writing my_2Dlist = my_2Dlist + [new_elem]. Once again, we wrapped the new element inside a pair of square brackets to keep the 2D structure of my_2Dlist.
Discussions

Appending to 2D lists in Python - Stack Overflow
this is the most bizarre functionality ... in Python. seems almost like a bug. 2021-11-22T22:26:19.01Z+00:00 ... Save this answer. ... Show activity on this post. ... In other words, all three list references refer to the same list instance. ... Save this answer. ... Show activity on this post. Came here to see how to append an item to a 2D array, but ... 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
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
arrays - Python: multi-dimensional lists - appending one 2D list into another list - Stack Overflow
I'm looking to create a master array/list that takes several two dimensional lists and integrates them into the larger list. For example I have a TableA[] which has dates as one array/list and pri... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 23, 2017
๐ŸŒ
Dot Net Perls
dotnetperls.com โ€บ 2d-python
Python - 2D List Examples - Dot Net Perls
import time # Nested, 3x2. nested_list = [] nested_list.append([ ... Python supports a special "array" from the array module. An integer array is more compact in memory than an integer list. We can create a flattened 2D array.
๐ŸŒ
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.
๐ŸŒ
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
Find elsewhere
๐ŸŒ
Iditect
iditect.com โ€บ faq โ€บ python โ€บ appending-to-2d-lists-in-python.html
Appending to 2D lists in Python
matrix = [[1, 2, 3], [4, 5, 6]] new_row = [7, 8, 9] matrix.append(new_row) "Python extend 2D list" Description: This query involves extending a 2D list in Python with additional elements.
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ python 2d array append
Python 2D array append
June 27, 2023 - To append elements to a 2D array in Python, you can use the append() method available for Python lists. Hereโ€™s the syntax for appending elements to a 2D array: ... Hereโ€™s an example that demonstrates how to append elements to a 2D array (a list of lists) in Python:
๐ŸŒ
Thedeveloperblog
thedeveloperblog.com โ€บ 2d-list-python
Python 2D List Examples
Jagged row lengths, where each row has a different number of elements, are also allowed. General idea. We create an empty list and add empty lists to it with append(). We can construct any rectangular (or jagged) list this way. In this example we built a 2 by 2 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...
๐ŸŒ
Snakify
snakify.org โ€บ two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
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()])
๐ŸŒ
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]] ?

๐ŸŒ
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 ...
๐ŸŒ
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 - Here's an example of one way to do it. TableA = [['01/01/2000', '$10'], ['02/01/2000', '$11']] If you entered this straight into the python interpreter, you'd define TableA as a list with two elements. Both of these elements are also lists.
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ two-dimensional-2d-lists-python-manish-v-
Two Dimensional (2D) Lists in Python
January 20, 2024 - Adding Rows: To add a new row to your 2D list, simply append a new list to the outer list.