Free tutorials in Hindi & English Daily computer, mobile and IT guides Beginner friendly learning
Blog · Python · 04 Jul 2026 · Hindi + English

Difference Between append() and extend() in Python

append() adds one element as-is (even a whole list becomes one item), extend() adds each element individually. Examples and output proof inside.

The one-line answer

append() adds its argument as a SINGLE item at the end; extend() adds EACH element of its argument individually. The difference only becomes visible when the argument is itself a list or other iterable.
a = [1, 2, 3]
b = [1, 2, 3]

a.append([4, 5])     # whole list becomes ONE item
b.extend([4, 5])     # each element added separately

print("append:", a)
print("extend:", b)
append: [1, 2, 3, [4, 5]] extend: [1, 2, 3, 4, 5]

Look carefully: after append the list has 4 items (the last one is a nested list), after extend it has 5 items.

Length proof

a = [1, 2, 3]
a.append([4, 5])
print(len(a), a[3])        # 4  [4, 5]  <- nested list!

b = [1, 2, 3]
b.extend([4, 5])
print(len(b), b[3])        # 5  4      <- plain number
4 [4, 5] 5 4

extend() works with any iterable

letters = ["a", "b"]

letters.extend("cd")           # string is iterable: adds 'c','d'
letters.extend(("e", "f"))     # tuple works
letters.extend({"g"})          # set works
print(letters)
['a', 'b', 'c', 'd', 'e', 'f', 'g']
Trap: letters.append("cd") would add the whole string "cd" as one item, but letters.extend("cd") splits it into 'c' and 'd' — because a string is an iterable of characters. This exact question appears in written tests.

Comparison table

Pointappend(x)extend(iterable)
Addsx as one single itemEvery element of the iterable
ArgumentAnythingMust be iterable
Length changeAlways +1+len(iterable)
Nested resultYes, if x is a listNever nested
Equivalentlist1 += list2

When to use which?

  • append() — adding one record: students.append("Aman"), or intentionally keeping a sub-list: matrix.append([1, 2, 3]).
  • extend() — merging two lists: all_marks.extend(class_b_marks).
  • Interview line: "append is +1 item, extend is +N items."

One-line answer

append() अपने argument को अंत में एक SINGLE item की तरह जोड़ता है; extend() argument के हर element को अलग-अलग जोड़ता है. यह अंतर तभी दिखता है जब argument खुद list या कोई iterable हो.
a = [1, 2, 3]
b = [1, 2, 3]

a.append([4, 5])     # पूरी list एक item बन गई
b.extend([4, 5])     # हर element अलग-अलग जुड़ा

print("append:", a)
print("extend:", b)
append: [1, 2, 3, [4, 5]] extend: [1, 2, 3, 4, 5]

ध्यान से देखें: append के बाद list में 4 items हैं (आखिरी एक nested list है), extend के बाद 5 items.

Length proof

a = [1, 2, 3]
a.append([4, 5])
print(len(a), a[3])        # 4  [4, 5]  <- nested list!

b = [1, 2, 3]
b.extend([4, 5])
print(len(b), b[3])        # 5  4      <- सादा number
4 [4, 5] 5 4

extend() किसी भी iterable के साथ काम करता है

letters = ["a", "b"]

letters.extend("cd")           # string iterable है: 'c','d' जुड़े
letters.extend(("e", "f"))     # tuple चलता है
letters.extend({"g"})          # set चलता है
print(letters)
['a', 'b', 'c', 'd', 'e', 'f', 'g']
Trap: letters.append("cd") पूरी string "cd" को एक item की तरह जोड़ता, लेकिन letters.extend("cd") उसे 'c' और 'd' में तोड़ देता है — क्योंकि string characters की iterable है. यही question written tests में आता है.

Comparison table

Pointappend(x)extend(iterable)
जोड़ता हैx को एक single item की तरहIterable का हर element
Argumentकुछ भीIterable होना ज़रूरी
Length changeहमेशा +1+len(iterable)
Nested resultहां, अगर x list हैकभी nested नहीं
Equivalentlist1 += list2

कब कौन-सा use करें?

  • append() — एक record जोड़ना: students.append("Aman"), या जानबूझकर sub-list रखना: matrix.append([1, 2, 3]).
  • extend() — दो lists merge करना: all_marks.extend(class_b_marks).
  • Interview line: "append है +1 item, extend है +N items."

Frequently Asked Questions

What is the difference between append and extend?

append(x) adds x as one single item (a list becomes a nested list), while extend(iterable) adds each element of the iterable individually to the end.

What happens if we extend a list with a string?

The string is split into individual characters because it is an iterable — ["a"].extend("bc") gives ["a","b","c"].

Is list1 += list2 same as append or extend?

It behaves like extend: each element of list2 is added individually to list1.