How to Access Array Element Using Array Indexing


In this example we will show how to access the NumPy array element using the array indexing in Python.

Source Code

import numpy as np

n = np.array([1, 2, 3, 4, 5, 6])

print('The first element is:', n[0])
print('The fourth element is:', n[3])
print(n[0] + n[3])

Output:

The first element is: 1
The fourth element is: 4
5
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments