THE WORLD'S LARGEST WEB DEVELOPER SITE

Python List insert() Method

❮ List Methods


Example

Insert the value "orange" as the second elemnent of the fruit list:

fruits = ['apple', 'banana', 'cherry']

fruits.insert(1, "orange")
Run example »

Definition and Usage

The insert() method inserts the specified value at the specified position.


Syntax

list.insert(pos, elmnt)

Parameter Values

Parameter Description
pos Required. A number specifying in which position to insert the value
elmnt Required. An element of any type (string, number, object etc.)

❮ List Methods