Source Code:
(back to article)
import array as arr # create an array of integers my_array = arr.array('i', [1, 2, 3, 4, 5]) # access the first element of the array print(my_array[0]) # Output: 1 # access the second element of the array print(my_array[1]) # Output: 2 # access the last element of the array print(my_array[-1]) # Output: 5
Result:
Report an issue