List insert() Method Syntax
list_name.insert(index, element)
Parameters:
- index: the index at which the element has to be inserted.
- element: the element to be inserted in the list.
Return : The insert()
method returns None
. It only updates the current list.
Python List insert() Method With Examples
Python List insert() method inserts an item at a specific index in a list.
Example:
Python3
# creating a list fruit = [ "banana" , "cherry" , "grape" ] fruit.insert( 1 , "apple" ) print (fruit) |
Output
['banana', 'apple', 'cherry', 'grape']