The extend()
method adds all the elements of an iterable (list, tuple, string, etc.) to the end of the list.
In this blog post, you will learn how to use the python list extend()
method.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Extend the list
my_list.extend([6, 7, 8, 9, 10])
Step 3: Print the list
print(my_list)
Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]