append() and extend() are two list methods used to add elements to a list, but they behave differently.
- append() adds a single item (of any type) to the end of a list.
- extend() adds all elements from an iterable (like a list, tuple, or set) to the end of the current list.
append() Method
append() method adds a single element to the end of a list. This element can be a number, string, list, or any object.
Syntax:
list.append(element)

a = ['geeks', 'for']
# Append 'geeks' at the end of 'a'
a.append('geeks')
print(a)
# Append an entire list to 'a'
a.append(['a', 'coding', 'platform'])
print(a)
Output
['geeks', 'for', 'geeks'] ['geeks', 'for', 'geeks', ['a', 'coding', 'platform']]
extend() Method
extend() method adds all elements from an iterable to the end of the current list. Unlike append(), it does not add the iterable as a single element; instead, each element is added individually.
Syntax:
list.extend(iterable)

a = ['geeks', 'for']
b = [6, 0, 4, 1]
#Add all elements of 'b' to the end of 'a'
a.extend(b)
print(a)
Output
['geeks', 'for', 6, 0, 4, 1]
Note: A string is also an iterable, so if we extend a list with a string, each character of the string is appended individually.
Key Difference Between append() and extend()
| Feature | append() | extend() |
|---|---|---|
| Purpose | Adds a single element to the end of the list. | Adds multiple elements from an iterable to the end of the list. |
| Argument Type | Accepts a single element (any data type). | Accepts an iterable (e.g., list, tuple). |
| Resulting List | Length increases by 1. | Length increases by the number of elements in the iterable. |
| Use Case | When we want to add one item. | When we want to merge another iterable into the list. |
Time Complexity | O(1) , as adding a single element is a constant-time operation. | O(k), where k is the number of elements in |