You can append the elements of one list to another with the "+=" operator. Note that the "+" operator creates a new list.

a = [1, 2, 3]
b = [10, 20]

a = a + b # Create a new list a+b and assign back to a.
print a
# [1, 2, 3, 10, 20]


# Equivalently:
a = [1, 2, 3]
b = [10, 20]

a += b
print a
# [1, 2, 3, 10, 20]

If you want to append the lists and keep them as lists, then try:

result = []
result.append(a)
result.append(b)
print result
# [[1, 2, 3], [10, 20]]
Answer from stackoverflowuser2010 on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-add-to-array
Python Array Add: How to Append, Extend & Insert Elements | DigitalOcean
April 15, 2025 - Learn how to add elements to an array in Python using append(), extend(), insert(), and NumPy functions. Compare performance and avoid common errors.
Discussions

Using square brackets: Extend() vs Append()
Kristian Woods is having issues with: Why when you use square brackets in append() - it creates a list inside a list? More on teamtreehouse.com
🌐 teamtreehouse.com
2
October 17, 2017
How to append 3d numpy array to a 4d array

Sounds like what you really need is a python list of 3D numpy arrays. Appending to a numpy array is possible with np.append or np.concat, but it's very expensive because it forces the entire array to be remade. Is there any reason you want a 4D array?

More on reddit.com
🌐 r/learnpython
8
1
March 10, 2019
numpy.append() in Python --- slower (faster) than appending to a List ?
That's right. A numpy array is a real array in a computer science sense, which means it cannot be resized. Since appending requires resizing, numpy is forced to create a whole new array with a bigger allocation and copy all the old data over before adding any new data. This takes a lot of time. Python lists are resizeable therefore appending is very fast. More on reddit.com
🌐 r/learnpython
2
0
July 2, 2020
Appending on a new line for new array, np.savetxt
Would you be able to write out a brief example of what you want the input/output to look like? It may help clear this up! More on reddit.com
🌐 r/learnpython
2
3
December 3, 2018
🌐
W3Schools
w3schools.com › python › gloss_python_array_add.asp
Python Add Array Item
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... You can use the append() method to add an element to an array.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.append.html
numpy.append — NumPy v2.1 Manual
Delete elements from an array. ... >>> import numpy as np >>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]]) array([1, 2, 3, ..., 7, 8, 9])
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-append-method
Python List append() Method - GeeksforGeeks
July 23, 2025 - When appending one list to another, the entire list is added as a single element, creating a nested list. ... Explanation: append() method adds the list [4, 5] as a single element to the end of the list a, resulting in a nested list.
🌐
Tutorialspoint
tutorialspoint.com › home › python › python array append method
Python Array Append Method
February 21, 2009 - Following is the syntax of the Python Array append() method − ... This method accepts the element that has to be appended. This method does not return any value. The following is the basic example of the Python Array append() method −
🌐
Real Python
realpython.com › python-append
Python's .append(): Add Items to Your Lists in Place – Real Python
October 21, 2023 - Here, you use .append() to add an integer number to an array of floating-point numbers. That’s possible because Python can automatically convert integer numbers into floating-point numbers without losing information in the process.
Find elsewhere
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python append element to array
Python Append Element to Array - Spark By {Examples}
May 31, 2024 - For example, you create an empty integer array arr and then use the append() method to add three integers to the array. import array # Use append() method # create an empty array arr = array.array('i') arr.append(5) arr.append(10) arr.append(15) ...
🌐
IONOS
ionos.com › digital guide › websites › web development › python append
How to use Python append to extend lists - IONOS
October 30, 2023 - However, arrays have certain limitations in that they can only hold elements of the same data type, and this data type must be specified when creating the array. Consequently, using the append() method to add elements of different data types to an array is not possible. Let’s illustrate this limitation with an example:
🌐
Centron
centron.de › startseite › numpy.append() in python – tutorial
numpy.append() in Python - Tutorial
July 2, 2025 - Master the use of numpy.append() to add elements to arrays in Python with ease. Ideal guide for enhancing your data manipulation skills.
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-append-an-element-into-an-array
Python Program to Append an Element Into an Array
May 15, 2023 - The element 9 is appended to the array, and which is added at the end of the array. The array module in Python allows us to create an array, and that can compactly represent an array.
🌐
DigitalOcean
digitalocean.com › community › tutorials › numpy-append-in-python
numpy.append() in Python | DigitalOcean
August 3, 2022 - In the second example, the array shapes are 1x2 and 2x2. Since we are appending along the 0-axis, the 0-axis shape can be different. The other shapes should be the same, so this append() will also work fine. ... Let’s look at another example where ValueError will be raised. >>> import numpy as np >>> >>> arr3 = np.append([[1, 2]], [[1, 2, 3]], axis=0) Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/function_base.py", line 4528, in append return concatenate((arr, values), axis=axis) ValueError: all the input array dimensions except for the concatenation axis must match exactly >>>
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.3 documentation
The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”). To add an item to the top of the stack, use append().
🌐
W3Schools
w3schools.com › python › python_arrays.asp
Python Arrays
Note: This page shows you how to use LISTS as ARRAYS, however, to work with arrays in Python you will have to import a library, like the NumPy library. Arrays are used to store multiple values in one single variable: ... An array is a special variable, which can hold more than one value at a time. If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:
🌐
freeCodeCamp
freecodecamp.org › news › append-in-python-how-to-append-to-a-list-or-an-array
Append in Python – How to Append to a List or an Array
January 7, 2022 - In this article, you'll learn about the .append() method in Python. You'll also see how .append() differs from other methods used to add elements to lists. Let's get started! What are lists in Python? A definition for beginners An array in programmi...
🌐
Namehero
namehero.com › blog › how-to-append-an-item-to-a-python-array
How to Append an Item to a Python Array
April 17, 2024 - To explicitly use arrays instead of lists in Python, you need to import the “array” module. Here’s a series of commands designed to show you how to create an array, append an item to it, and print the output:
🌐
AskPython
askpython.com › home › how to append an array in python?
How to append an Array in Python? - AskPython
January 16, 2024 - Python append() method can be framed here to add/append elements to the end of the list. ... The list or the element gets added to the end of the list and the list is updated with the added element. ... We can create an array using the Array module and then apply the append() function to add elements to it. ... unicode: It represents the type of elements to be occupied by the array. For example, ‘d’ represents double/float elements.
Top answer
1 of 2
3
Hi Kristian, These two functions exist and behave differently because you might want to do one of two things: Add individual items to a list one at a time (append) Add a list of items to a list all at once (extend) Your last example works, but there's not really a good reason to use extend like that, since you could just use append if you really wanted to add a list to the list. In fact, it's pretty rare that you would use your first example as well. It's just not that common to add an actual list to an existing list. You're more commonly going to want to add items. Python lists are super-flexible, but most of the time they'll just be a collection of the same thing. Here's a realistic example: I've got a to-do web app, and I have an input on a website. If a user puts a single item into the input and hits submit, I run: ```python todos: ["Go to the store", "Make dinner"] user inputs: "Make an appointment for next week" we run: todos.append("Make an appointment for next week") todos: ["Go to the store", "Make dinner", "Make an appointment for next week"] ``` Now I add a feature where users can add multiple items at once using multiple input boxes. If they fill in multiple input boxes, the inputs come through as a list: ```python todos: ["Go to the store", "Make dinner"] user inputs: ["Make an appointment", "Clean the kitchen"] we run: todos.extend(["Make an appointment", "Clean the kitchen"]) todos: ["Go to the store", "Make dinner", "Make an appointment", "Clean the kitchen"] ``` The short version is that for "one-dimensional" lists (ones that don't have other lists in them), append is for adding one item, and extend is for adding a list of items. As you've discovered, there's more complexity than this, but 90% of the time this is how you'll use them. Hope that helps! Cheers :beers: -Greg
2 of 2
1
Hi there! The extends function exists specifically so that it can add every item of an iterable to an already existing list. The append item adds one object to a list. In your example, you append [4,5]. That list is considered one object and in and of itself. The extend breaks apart the iterable and adds each item separately. In your final example, you give array.extend([[4,5]]). The argument there is a list, that contains exactly one item which is itself a list. Take a look at this Python documentation (https://docs.python.org/3/tutorial/datastructures.html). At the very top are the specs for the append and extend methods. As you'll see the append adds an object, while the extends takes an iterable and breaks it apart to put each item in the iterable onto the list you've designated. I wrote this little example, which might help you see it better when you try it with a string. ```py greeting = [] greeting2 = [] greeting.append("Hi") greeting.append("Kristian") greeting2.extend("Hi") greeting2.extend("Kristian") print(greeting) print(greeting2) ``` Hope this helps! :sparkles:
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › add elements to python array
Add Elements to Python Array (3 Methods)
December 15, 2025 - import array a = array.array('i', [1,2,3]) print("Array before appending:", a) a.append(4) print("Array after appending:", a) The method extends the existing list with a new element, which matches the array type code.
🌐
AskPython
askpython.com › home › python add elements to an array
Python add elements to an Array - AskPython
January 16, 2024 - The following can be used to represent arrays in Python: ... By using append() function: It adds elements to the end of the array. By using insert() function: It inserts the elements at the given index.