How to insert an object at a given index in Python?

How to insert an object at a given index in Python?
0

#1

Can you help me in inserting an object in python at a given index.


#2

my_array.insert(index, object)


#3

In order to insert an object in python, let’s build a link first-

>>> a=[1,2,4]

Now, we use the method insert. The first argument is the index at which to insert, the second is the value to insert.

>>> a.insert(2,3)
>>> a