Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Python – Extend List by Appending – extend() Function with Examples

extend() function is used to extend the list by appending all the items from the iterable.

Syntax of extend() Function

The syntax of extend() function in Python is:

Here, the elements of iterable are added to the end of list.


Parameters of extend() Function in Python

iterable – Where iterable is any list of elements. This parameter is required.



extend() function is available and compatible with both Python 2.x and 3.x. This function is one of python list methods.


Return Value of extend() Function in Python

extend() function does not return anything.


Python extend() Function Example 1

['Broccoli', 'Potato', 'Carrot', 'Peas', 'Onions', 'Tomato', 'Cucumber']


Python extend() Function Example 2

Adding elements of tuple and set to list.


['Broccoli', 'Potato', 'Carrot', 'Peas', 'Onions', 'Tomato', 'Cucumber']
['Broccoli', 'Potato', 'Carrot', 'Peas', 'Onions', 'Tomato', 'Cucumber', 'Radish', 'Garlic']

LearnAndLearn.com © 2018 - All rights reserved