Skip to content
Exercise · Q5

Q.Differentiate between append() and extend() functions of list.

Sikkim CbseNCERTSubjective· 3mImportance★★★★★est
73% · 19/26 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

append(x) adds x to the end as ONE element (so appending a list nests it and the length grows by exactly 1), while extend(seq) walks through seq and appends each of its elements individually (length grows by len(seq)).

The idea. Both are in-place list methods that grow a list at its end and return None — the difference is entirely in how the argument is treated: as an object (append) versus as an iterable of objects (extend).

Point-by-point comparison:

Aspectappend(x)extend(seq)
What is addedx itself, as a single elementeach element of seq, one by one
Effect of passing a listthe list is nested insideits items are merged in flat
Growth in lengthalways +1+len(seq)
Argument requirementany object at allmust be iterable (list, tuple, string…)
Equivalent operationL[len(L):] = [x]L = L + list(seq) done in place (like +=)

Demonstration:

L1 = [10, 20]
L1.append([30, 40])          # one nested element
print(L1, "-> length", len(L1))

L2 = [10, 20]
L2.extend([30, 40])          # two separate elements
print(L2, "-> length", len(L2))

L3 = [10, 20]
L3.extend("ab")              # a string is iterable: adds 'a', 'b'
print(L3)

Expected output:

[10, 20, [30, 40]] -> length 3
[10, 20, 30, 40] -> length 4
[10, 20, 'a', 'b']
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.