How to append multiple values to a list in Python
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Python, list.append(...) adds exactly one object to the end of a list. If you want to add several values, the right tool is usually extend(...) or list concatenation, depending on whether you want to modify the existing list or create a new one.
This distinction matters because “append multiple values” can mean two different things. Sometimes you want to add several separate elements. Sometimes you want to add one nested list as a single element. Python treats those cases differently.
append Adds One Object
The append method never spreads an iterable into multiple list elements. It appends the argument as one item.
Output:
That is correct behavior, but it surprises people who expected [1, 2, 3, 4].
Use extend for Multiple Elements
If you want to add each element from another iterable, use extend.
Output:
extend iterates over the provided iterable and appends each element individually.
It works with lists, tuples, sets, generators, and strings, although strings need caution because they extend character by character.
You Can Also Use +=
The += operator is another concise way to extend a list.
For lists, this mutates the existing list similarly to extend.
This is convenient, but extend is often clearer when you want to emphasize that elements are being added from another iterable.
Create a New List With Concatenation
If you do not want to modify the original list, use + to create a new one.
This leaves original unchanged and produces a fresh list.
That is useful when immutability-by-convention or functional-style code is important.
Add Multiple Values in a Loop
Sometimes the values are generated over time. In that case, a loop plus append is fine.
This is not wrong just because extend exists. Use the style that matches how the values are produced.
Be Careful With Strings
A common surprise is extending with a string.
Output:
If you meant to add the whole string as one element, use append("bc") instead.
Choosing the Right Method
Use this rule of thumb:
- '
append(x)whenxshould become one new list element' - '
extend(xs)when each element ofxsshould be added individually' - '
+when you want a new list rather than mutating the old one' - a loop with
appendwhen values arrive one at a time
Once you think in terms of “one object” versus “many elements,” the choice becomes obvious.
Common Pitfalls
A common mistake is using append([3, 4]) when the desired result was to add two separate numbers. That creates a nested list.
Another mistake is using extend with a string and accidentally splitting it into individual characters.
Developers also sometimes use + inside a loop, which repeatedly creates new lists and can be less efficient than extending one list in place.
Finally, do not treat append and extend as interchangeable. They express different structure.
Summary
- '
appendadds one object to the list.' - '
extendadds each element from an iterable.' - '
+=behaves like in-place extension for lists.' - '
+creates a new list instead of mutating the existing one.' - The key question is whether you want one new element or many new elements.

