What is the difference between append() and extend() on a list?
Reviewed by Gurusankar M.
Short Answer
`append(x)` adds x as a single element (the list grows by one, even if x is itself a list). `extend(iterable)` adds each element of the iterable individually (the list grows by len(iterable)). Use append for one item, extend to merge another sequence in.
On this page
Concept Made Simple
Coffee Chat Question
βWhat is the difference between append() and extend() on a list?β
Remember It Faster
Mind Map Answer
- append(x)
- adds ONE element (x itself)
- extend(it)
- adds each element of it
- a + b
- returns a NEW list (no mutation)
Learn by Doing
Hands-on Keyboard
nums = [1, 2]
nums.append([3, 4]) # nested
print(nums) # [1, 2, [3, 4]]
nums = [1, 2]
nums.extend([3, 4]) # flattened in
print(nums) # [1, 2, 3, 4][1, 2, [3, 4]] [1, 2, 3, 4]
Think Beyond the Expected
What If?
What does `nums.append([3, 4])` produce and why does it surprise people?
It produces `[1, 2, [3, 4]]` β the whole list is added as a single nested element, not merged. People expect flattening; that's what `extend` (or `+=`) does. append always adds exactly one item, whatever its type.
Real World
Accidentally using append where you meant extend creates nested lists that break later iteration β a very common beginner bug when building up results from multiple sources.
Interviewer's Expectation
Keywords they're listening for:
- append adds one element
- extend adds each element
- append([...]) nests
- += behaves like extend
Common Mistakes
- Using append when you meant extend (nesting)
- Assuming a + b mutates a
- Confusing extend with a shallow copy
Best Practices
- append for a single item, extend to merge
- Use += for in-place extend
- Prefer list comprehension to flatten nested lists
Follow-up Questions
- How is `list += other` different from `list = list + other`?
- What's the time complexity of append?
- How do you flatten a list of lists?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Lists (Python) Interview question: "What is the difference between append() and extend() on a list?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair