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