Chapters
Python114 chapters

ReferenceList methods

list.insert()

Puts an item at a position, pushing the rest along.

Signature

items.insert(index, item)

Parameters

NameMeans
indexwhere it should land
itemwhat to put there

Returns

None.

Example

Python
names = ["Ada", "Kat"]
names.insert(1, "Grace")
print(names)
names.insert(99, "Last")
print(names)

Output

['Ada', 'Grace', 'Kat']
['Ada', 'Grace', 'Kat', 'Last']

See also