Python List extend() Method

Example

Add elements from cars to fruits list:

fruits = ['apple', 'banana', 'cherry']
cars = ['Porsche', 'BMW', 'Volvo']
fruits.extend(cars)

Run Instance

Definition and Usage

The extend() method adds the specified list elements (or any iterable elements) to the end of the current list.

Syntax

list.extend(iterable)

Parameter Value

Parameter Description
iterable Required. Any iterable object (list, set, tuple, etc.).

More Examples

Example

Add tuple to fruits list:

fruits = ['apple', 'banana', 'cherry']
points = (1, 4, 5, 9)
fruits.extend(points)

Run Instance