Python List extend() Method

❮ List Methods


Example

Add the elements of cars to the fruits list:

fruits = ['apple', 'banana', 'cherry']

cars = ['Ford', 'BMW', 'Volvo']

fruits.extend(cars)
Try it Yourself »

Definition and Usage

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


Syntax

list.extend(iterable)

Parameter Values

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

More Examples

Example

Add a tuple to the fruits list:

fruits = ['apple', 'banana', 'cherry']

points = (1, 4, 5, 9)

fruits.extend(points)
Try it Yourself »

❮ List Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.