List insert(index, obj) Method

In Python Built-In List insert(index, obj) method is used to inserts object obj into list at offset index.

Syntax:
There are 2 Parameters used in the list index(index, obj) method: 
obj Shows the object to be inserted in the list.
index Shows where the object obj to be inserted.
Example:
#method

list1 = ['TOM', 'JOHN', 'ALICE']
list1.insert( 1, 2020)
print ("Final List is : ", list1)

Comments are closed.