Friday, April 13, 2018

How to access elements in Arrays?


Accessing Array Element

We can access each element of an array using the index of the element. The below code shows how

from array import *

array1 = array('i', [10,20,30,40,50])

print (array1[0])

print (array1[2])

When we compile and execute the above program, it produces the following result − which shows the element is inserted at index position 1.

Output

10
30