---
title: "Explain the difference between the \"append\" and \"extend\" methods in Python lists."  
description: "Explain the difference between the \"append\" and \"extend\" methods in Python lists."  
author: "Steilla Mitchel"  
published: 2023-07-04  
updated: 2023-07-05  
canonical: https://www.mindstick.com/forum/158962/explain-the-difference-between-the-append-and-extend-methods-in-python-lists  
category: "python"  
tags: ["python", "methods"]  
reading_time: 2 minutes  

---

# Explain the difference between the "append" and "extend" methods in Python lists.

[Explain the difference](https://www.mindstick.com/forum/156125/can-you-explain-the-difference-between-organic-and-paid-results) between the 'append' and '[extend](https://www.mindstick.com/forum/2353/how-to-implements-of-inheritance-in-java)' [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) in [Python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python) lists.

## Replies

### Reply by Aryan Kumar

The `append()` and `extend()` methods are both used to add elements to a list in Python. However, they have different behaviors.

The `append()` method adds a single element to the end of a list. The length of the list itself will increase by one. For example, the following code will add the element `4` to the end of the list `list1`:

Python

```plaintext
list1 = [1, 2, 3]
list1.append(4)
print(list1)
```

The output of the code is:

Code snippet

```plaintext
[1, 2, 3, 4]
```

The `extend()` method iterates over its argument adding each element to the list, extending the list. The length of the list will increase by however many elements were in the iterable argument. For example, the following code will add the elements `5` and `6` to the end of the list `list1`:

Python

```plaintext
list1 = [1, 2, 3]
list1.extend([5, 6])
print(list1)
```

The output of the code is:

Code snippet

```plaintext
[1, 2, 3, 5, 6]
```

Here is a table summarizing the differences between `append()` and `extend()`:

| Feature | `append()` | `extend()` |
| --- | --- | --- |
| Adds a single element | Yes | No |
| Adds elements from an iterable | No | Yes |
| Increases the list length by one | Yes | Length of iterable |
| Time complexity | O(1) | O(k) |

Here are some examples of how `append()` and `extend()` can be used:

Python

```plaintext
# Append a single element to a list
list1 = [1, 2, 3]
list1.append(4)
print(list1)

# Extend a list with the elements of another list
list2 = [5, 6]
list1.extend(list2)
print(list1)

# Extend a list with the elements of a string
list1 = [1, 2, 3]
list1.extend("abc")
print(list1)
```


---

Original Source: https://www.mindstick.com/forum/158962/explain-the-difference-between-the-append-and-extend-methods-in-python-lists

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
