VOOZH about

URL: https://www.geeksforgeeks.org/python/python-list-extend-method/

⇱ Python List extend() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python List extend() Method

Last Updated : 27 May, 2026

extend() method is used to add all elements from another iterable to the end of a list. It updates the original list by adding each element one by one.

In this example, extend() adds all elements of one list to another list.


Output
[1, 2, 3, 4, 5]

Explanation: extend(b) adds all elements of list b to the end of list a.

Syntax

list.extend(iterable)

  • Parameters: iterable - Any iterable object such as a list, tuple, set or string.
  • Return: It does not return any value and it modifies the original list directly.

Examples

Example 1: In this example, elements of a tuple are added to a list using extend(). Each tuple element is inserted separately into the list.


Output
[1, 2, 3, 4]

Explanation: extend(b) adds all elements of tuple b to list a.

Example 2: Here, a set is used with extend(). All elements of the set are added to the list.


Output
[10, 20, 40, 30]

Explanation: extend(b) inserts all elements from set b into list a. The order may vary because sets are unordered.

Example 3: This example, passes a string to extend(). Each character of the string is added separately to the list.


Output
['P', 'y', 't', 'h', 'o', 'n']

Explanation: extend(b) adds each character of the string b separately to the list.

Comment