In this example we will show how to access elements from the NumPy arrays using negative indexing in Python.
Source Code
import numpy as np
n = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print('The last element of the first array:', n[0, -1])
Output:
The last element of the first array: 4