Chapters
Python114 chapters

ReferenceList methods

list.extend()

Adds each item from an iterable to the end.

Signature

items.extend(iterable)

Parameters

NameMeans
iterablewhose items are added one by one

Returns

None.

Example

Python
a = ["Ada"]
a.extend(["Grace", "Kat"])
print(a)

b = ["Ada"]
b.append(["Grace", "Kat"])
print(b, len(b))

Output

['Ada', 'Grace', 'Kat']
['Ada', ['Grace', 'Kat']] 2

See also