.extend()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jun 4, 2021Updated Apr 4, 2023
Contribute to Docs

Adds list elements to end of the list.

Syntax

list.extend(iterable)

This will place elements passed in an iterable (list, tuple, or string) as new elements at the very end of the list.

.extend() does not return any value.

Examples

To add grocery_new to the end of the grocery list:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

It works for any other type of iterables:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy