The insert() method adds an element at a specific index, shifting existing elements right. Syntax: list.insert(index, element).
Given [1, 2, 3], calling insert(1, 99) produces [1, 99, 2, 3]. The goes at index ; everything from index onward shifts right.
Edge cases:
insert(0, x)adds at the beginninginsert(len(list), x)adds at the end (same asappend)- Negative indices work:
insert(-1, x)inserts before the last element
insert() is because elements must shift. For frequent insertions at arbitrary positions, consider collections.deque or linked lists instead.