Python List extend() Method

Adds to the end of the current list the items in another list.

Syntax

Python
list.extend(iterable)

Parameters

ParameterDescription
iterable Required. The iterable object used to extend the current object. This can be any iterable type such as list, set, dictionary etc

Example

Python
cars = ['Ford', 'Chevrolet']
foreignCars = ['BMW', 'Mercedes']
cars.extend(foreignCars)
print(cars)

Output

['Ford', 'Chevrolet', 'BMW', 'Mercedes']