Table of contents
1.
Introduction
2.
What is Append() in Python?
2.1.
Syntax of append() function
2.2.
Examples of Python append() function
2.3.
Python
2.4.
Python
3.
What is Extend() in Python?
3.1.
Syntax of Extend() Function in Python
3.2.
Examples of Python extend() function
3.3.
Python
3.4.
Python
4.
Difference between append() and extend() in Python:  append vs. extend
5.
Key Differences Between append and extend in Python
6.
Frequently Asked Questions
6.1.
What is the difference between append and extend in Python?
6.2.
Is append faster than insert in Python?
6.3.
How does the extend() function works in Python?
6.4.
What will be the output of append and extend if an iterable is passed as an argument?
7.
Conclusion
Last Updated: Aug 11, 2025
Easy

Difference Between Append and Extend in Python

Introduction

A list is a contiguous allocation of data. The elements in the list need not be of the same data types. Due to this reason, it is one of the best advantages of using lists in Python. This feature is also known as heterogeneous property. We can include different data types in lists: integers, strings, chars, etc. An example of a heterogeneous list can be [1, 2, 3, 4, ‘a’, “coding”].
 

The main difference between the append() and extend() functions in Python is how they add elements to a list.

  • append() adds a single element to the end of the list as a whole.
  • extend() adds multiple elements from an iterable (such as a list, tuple, or set) to the list.
     

In short, append() takes one item and adds it as-is, while extend() takes an iterable and adds its elements individually. 

Difference between append and extend in Python

In this blog, we will discuss append() and extend() in detail, and at the end, we will see the difference between append and extend in Python.

What is Append() in Python?

The append() function is one of the built-in functions used to add an element to a list. The main point about the append() function is that the element can only be added at last using it. As lists are heterogeneous, the input argument for append can also be of any data type.

append() in Python

The append function makes changes in the original list instead of creating a copy of the list. Every time we call the append function, the length of the list increases by 1, this is one of the difference between append and extend in Python.

Syntax of append() function

the_list.append(element)

 

“the_list” is the list to which the element needs to be added. The element can be of any data type. The dot (.) in the syntax is also equally important as it specifies the list. Here,  the function will be implemented to the list before the dot.

Examples of Python append() function

Example 1:

  • Python

Python

prime_list = [2,3,5,7,11]

prime_list.append(13)

print(prime_list)
You can also try this code with Online Python Compiler
Run Code

 

Output

[2,3,5,7,11,13]

 

Explanation:

In the above example, we use a list depicting prime numbers. The append() function adds the following smallest prime number to the list.
 

Example 2

  • Python

Python

mix_list = ["Welcome", "to", "coding"]

mix_list.append("ninjas")

print(mix_list)
You can also try this code with Online Python Compiler
Run Code

 

Output

['Welcome', 'to', 'coding', 'ninjas']

 

Explanation:

In the above code, append is used to add a string “ninjas” to the given list; this shows that we can use the append() function for different data types.

Refer to our article Append in Python for further reading.

What is Extend() in Python?

The extend() function is a built-in function that adds multiple elements to a list. The main point about the extend is that the input is an iterable such as strings, lists, etc. It iterates over its argument and appends every element to the specified list. In the case of append(), it appends the iterable as a single element; this is a significant difference between append and extend in Python. As lists can be heterogeneous, the input argument for extend can also be of any data type.

extend() in Python

The extend function makes changes in the original list instead of creating a copy of the list. Every time we use the extend function, the list's length increases by the length of the argument.

Syntax of Extend() Function in Python

the_list.extend(iterable_object)

 

“the_list” is the list to which the element needs to be added. The iterable_object can be a string, list, or tuple. The dot (.) in the syntax is also equally important as it specifies the list.

Examples of Python extend() function

Example 1:

  • Python

Python

list_of_seasons = ["Summer", "Winter"]
list_of_seasons.extend(["Autumn", "Spring"])
print(list_of_seasons)
You can also try this code with Online Python Compiler
Run Code


Output

['Summer', 'Winter', 'Autumn', 'Spring']

 

Explanation:

In the above example, the list depicts the seasons. The extend() function adds the remaining seasons to the list.

 

Example 2:

  • Python

Python

mix_list = [1, "one", 2, "two"]
mix_list.extend([3,"three"])
print(mix_list)
You can also try this code with Online Python Compiler
Run Code

 

Output

[1, 'one', 2, 'two', 3, 'three']

 

Explanation:

In the above code, extend is used to add [3, “three”] to the given list. This shows that extend() function can be used for heterogeneous lists, tuples, strings, etc. 

We learned about append and extend in detail and learned their functions. Now, let's discuss some key points of the difference between append and extend in Python.

Difference between append() and extend() in Python:  append vs. extend

In this section of the blog, we will compare the functions to add elements in a list, append and extend, about which we have learned in detail until now. Now it's time to discuss the difference between append and extend in Python.

Parameters

append

extend

Input argumentThe input argument can be of different data types.The input argument is iterable and can be of different data types.
UsageIt is used to add a single element in a list in single use.It is used to add multiple elements in a list in single use.
Addition The element as the argument is added to the end of the list.Each element in the iterable argument is added to the end of the list. 
Behavior with IterableAn iterable argument will get appended as a single element in the list.All elements of an iterable argument will be appended in the list.
List Length IncreaseThe length of the list increases by one after every use of the append() function.The length of the list increases by the length of the argument after every use of the extend() function.
Time complexityIt has a time complexity of O(1).It has a time complexity of O(len), where len is the length of the argument. 

Learn more, Difference Between Structure and Union

Key Differences Between append and extend in Python

Function Purpose:

  • append(): Used to add a single item to the end of a list.
  • extend(): Used to add each item from an iterable to the end of the list.

 

Handling of Existing Lists:

  • append(): Adds the entire argument as a single new element to the list.
  • extend(): Adds each element of the iterable to the list, effectively merging it with the list.

 

Impact on Nested Lists:

  • append(): Adds a nested list as a single element, resulting in a list within a list.
  • extend(): Flattens the nested list and adds its elements individually to the original list.

 

Use Case:

  • append(): Ideal for adding a single item such as an integer, string, or another list.
  • extend(): Ideal for combining lists or adding multiple items at once.

Frequently Asked Questions

What is the difference between append and extend in Python?

The append() adds the element passed as the argument to the end of the list, and the extend() adds every element of the argument to the end of the list. The time complexity of the append is O(1), whereas, for the extend, it is O(length of argument).

Is append faster than insert in Python?

Yes, append() is generally faster than insert() in Python. append() adds an element to the end of the list with a time complexity of O(1), while insert() can require shifting elements, resulting in a time complexity of O(n).

How does the extend() function works in Python?

The extend() function adds multiple elements to the end of a list in a single use. It iterates over the argument and adds every element to the end. The changes are made in the original list only.

What will be the output of append and extend if an iterable is passed as an argument?

If an iterable is given as input to extend() function, it adds every element of the argument to the list. But in the case of the attend() function, it will add the argument as a single element to the list. 

Conclusion

append() and extend() both add elements to the end of a list, but append() adds its argument as a single item, while extend() adds each element from an iterable individually. This makes extend() suitable for merging lists or adding multiple elements at once.

We discussed their syntax with some examples, and in the end, we summarised the difference between append and extend in Python in a table.

If you want to learn more about Python, do visit 

Live masterclass