When beginners add items to a Python list, they often mix up append() and +. Both seem to “add something,” but they do different things, especially when the thing you add is another list.
This note focuses on one key difference: append() adds the whole object as one element; + combines two lists into a new list.
Common Mistake
Suppose we have this list:
items = [1, 2]
items.append([3, 4])
print(items)
Many students expect:
[1, 2, 3, 4]
But the actual output is:
[1, 2, [3, 4]]
The list [3, 4] was not unpacked. It was added as one whole element inside items.
Core Idea
append() means: add one element to the end of a list.
The key phrase is “one element.” Whether you pass in a number, a string, or another list, append() treats it as one element.
items = [1, 2]
items.append(3)
print(items)
Output:
[1, 2, 3]
This feels natural because 3 is a single element.
But if you write:
items = [1, 2]
items.append([3, 4])
print(items)
the output is:
[1, 2, [3, 4]]
because the list [3, 4] itself becomes one element.
Use + to Combine Two Lists
If you want [1, 2, 3, 4], use +:
items = [1, 2]
new_items = items + [3, 4]
print(new_items)
Output:
[1, 2, 3, 4]
Here, + connects two lists and creates a new list. It does not put [3, 4] inside as one element; it places 3 and 4 after the original items.
append() Changes the Original List
There is another important difference: append() changes the original list in place.
items = [1, 2]
items.append(3)
print(items)
Output:
[1, 2, 3]
The original items has changed.
But + usually creates a new list:
items = [1, 2]
new_items = items + [3]
print(items)
print(new_items)
Output:
[1, 2]
[1, 2, 3]
This difference will matter later when you learn about list mutability.
Comparison
| Code | Result | Good for |
|---|---|---|
items.append(3) |
[1, 2, 3] |
Adding one single element |
items.append([3, 4]) |
[1, 2, [3, 4]] |
Adding the whole list as one element |
items + [3, 4] |
[1, 2, 3, 4] |
Combining two lists |
extend() Can Add Items One by One
If you want to change the original list and add each item from another list, use extend():
items = [1, 2]
items.extend([3, 4])
print(items)
Output:
[1, 2, 3, 4]
A simple rule:
append()adds one thing.extend()adds items from another list one by one.+combines two lists and gives a new list.
Practice
- If
items = [1, 2], what isitemsafteritems.append([3])? - If
items = [1, 2], what is the result ofitems + [3]? - Challenge: without using
+, add[3, 4]item by item to[1, 2].
One-Sentence Takeaway
append() adds the whole object as one element; + combines two lists into a new list.
Next time you see an extra pair of brackets inside a list, check whether you used append([ ... ]).
Questions or feedback?
Have a question about this article or want to suggest an improvement? Send us an email.
