Function Details: insert

Description


Insert an item at a given position.


Extended Description


The insert() method adds an item to the list at a specified position. It modifies the list in-place and doesn't return a new list. The index specifies where the new element should be inserted, and all elements after this position are shifted to the right.


Function Signature



Module: list

Class: list

Parameters



Parameter List


  • index: int
  • object: Any

Return


This method doesn't return a value. It modifies the list in-place.


Return Type


None

Output

Explanation

This example demonstrates the basic usage of insert(). It adds the element 4 at index 1, shifting the existing elements to the right.