Python List Extend()

Python extend() is an inbuilt function that adds the specified list elements (or any iterable) to the end of the current list. The extend() method extends the  list by adding all items of the list (passed as an argument) to an end.

Python list extend() method appends the contents of seq to list. The extend() method extends the list by adding all elements of a list (passed as an argument) to the end. Here, the items of list2 are added to the end of list1.

Syntax

The syntax for the Python list extend() method is the following.

list.extend(iterable)

#python #python list extend

Python list extend: How to Add Element in the List
1.30 GEEK