Python List Extend Method

title: List Extend Method

List Extend Method

There are many methods for lists, you can explore all of them by typing help(list) in your python console.
One of them is the extend function which, as the name says extends the list by adding all items of a list (passed as an argument) to the end.

Example Usage

cities = ["San Francisco", "Los Angeles", "New York"] cities_in_texas = ["San Antonio", "Austin", "Dallas"] cities.extend(cities_in_texas) print(cities)


["San Francisco", "Los Angeles", "New York", "San Antonio", "Austin", "Dallas"]

More Information:

The official documentation for extend() can be found here

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.