Insert value in an array using insert method

suggest change

We can use the insert() method to insert a value at any index of the array. Here is an example :

my_array = array('i', [1,2,3,4,5])
my_array.insert(0,0)
#array('i', [0, 1, 2, 3, 4, 5])

In the above example, the value 0 was inserted at index 0. Note that the first argument is the index while second argument is the value.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents