Python List insert() Method
Example
Insert the value "orange" as the second element into the fruits list:
fruits = ['apple', 'banana', 'cherry'] fruits.insert(1, "orange")
Definition and Usage
The insert() method inserts the specified value at the specified position.
Syntax
list.insert(position, element)
Parameter Value
Parameter | Description |
---|---|
position | Required. Number, specifying the position at which the value is to be inserted. |
element | Required. Element, of any type (string, number, object, etc.). |