Home >>Python List Methods >Python List insert() Method

Python List insert() Method

Python List insert() Method

Python list insert() method is used to insert the specified value at the specified position of the given input list.

Syntax:
list.insert(pos, elmnt)

Parameter Values

Parameter Description
pos This is a required parameter. It defines a number specifying in which position to insert the value.
elmnt This is a required parameter. It defines an element of any type.
Here is an example of Python insert() method:

a = ['Abhi', 'Mike', 'Jerry']
a.insert(2, "Jerry")
print(a)

Output:
['Abhi', 'Mike', 'Jerry', 'Jerry']
Example 2:

fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
print(fruits)

Output:
['apple', 'orange', 'banana', 'cherry']