Python Array Implementation

Author: Al-mamun Sarkar Date: 2020-03-28 13:40:09

Python array implementation. The following code shows how to use an array in the Python programming language.

Code:

from array import *

test_array = array('i', [10, 40, 50, 60, 30, 80])
test_array.insert(1, 600)

for item in test_array:
    print(item)

test_array.remove(30)

print(test_array)
print(test_array.index(60))

test_array[2] = 80
print(test_array)

 

Output:

10
600
40
50
60
30
80
array('i', [10, 600, 40, 50, 60, 80])
4
array('i', [10, 600, 80, 50, 60, 80])