concept extend() in category python

appears as: extend()
Hello World! Third Edition

This is an excerpt from Manning's book Hello World! Third Edition.

You already saw how to add things to a list using append(). But there are other ways. In fact, there are three methods for adding things to a list—append(), extend(), and insert():

Extending the list: extend()

extend() adds several items to the end of a list:

>>> letters.extend(['p', 'q', 'r'])
>>> print(letters)
['a', 'b', 'c', 'd', 'e', 'n', 'g', 'p', 'q', 'r']

Notice that what’s inside the round brackets of the extend() method is a list. A list has square brackets, so for extend(), you could have both round and square brackets.

Everything in the list you give to extend() gets added to the end of the original list.