Home >>Python List Methods >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 | 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. |
a = ['Abhi', 'Mike', 'Jerry']
a.insert(2, "Jerry")
print(a)
fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
print(fruits)