Tuesday, June 29, 2021

Insertion and deletion in Array

To insert a data into an array list, python provides us with insert method. The syntax is:

array_list . insert ( index_value , data_element )
 

To delete an element from the array list, python provide us with remove method. The syntax is:

array_list . remove ( data_element )

In our car Array, let us add a new car, tesla at index 1, and then we print the car Array. 

Then we remove one car, toyota, from the car Array and again print the Array

See the code below


Now let’s run the above piece of code and see whether our insertion and deletion was successful or not:

 

Try some more examples on our own to master the operations on array.

Share:

0 comments:

Post a Comment