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']

Similar Reads

Definition and Use of List insert() Method

...

List insert() Method Syntax

List insert() method in Python is very useful to insert an element in a list. What makes it different from append() is that the list insert() function can add the value at any position in a list, whereas the append function is limited to adding values at the end....

How to Insert into Python List at Index?

list_name.insert(index, element)...

More Examples on Python List insert() Method

Using Python list insert() function you can easily insert an item to a given index in Python list....