In this tutorial, you will learn what is the main difference between the append and extend methods of the Python List.
Difference between append and extend method of Python list
The append method only adds one item to the end of the list at a time. But the extend method takes an iterable as the parameter, so it inserts multiple elements at the end of the list at a time.
>>> a = [12, 20, 74] >>> a.append('Hello Python') >>> print(a) [12, 20, 74, 'Hello Python'] >>>
>>> x = [54, 32, 45] >>> x.extend(['Hello Python', 85, 29]) >>> print(x) [54, 32, 45, 'Hello Python', 85, 29] >>>