Skip to content
Exercises · Q5

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

Puducherry TnboardTextbookSubjective· 3mImportance★★★★★est
43% · 13/30 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 its argument as one single element (even if it's a list — it gets nested); extend(iterable) iterates over its argument and adds each element separately. After adding a 2-element list, append grows the list by 1, extend by 2.

Side-by-side demonstration:

list1 = [10, 20, 30]
list2 = [10, 20, 30]

list1.append([40, 50])    # one nested element in
list2.extend([40, 50])    # two separate elements in

print("append:", list1, "-> length", len(list1))
print("extend:", list2, "-> length", len(list2))
append: [10, 20, 30, [40, 50]] -> length 4
extend: [10, 20, 30, 40, 50] -> length 5

The differences, point by point

Aspectappend(x)extend(iterable)
What it addsx as one element, whatever it isevery element of the iterable, one by one
Length grows byexactly 1len(iterable)
Passing a listthe list is nested insideits elements are merged in flat
Argument typeanything (int, string, list, …)must be an iterable (list, string, tuple, …)
In place?yes, returns Noneyes, returns None

Why the difference matters

  • list1.append([40, 50]) makes list1[3] the list [40, 50] — to reach 40 you'd write list1[3][0]. Usually that nesting is an accident, caused by using append where extend was meant. …

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.