In the previous blog, I have showed you how to create a NumPy array. In this blog, I will show you how to access data inside the array using index.
First of all, you can create a NumPy array for the example
import numpy as np
list_of_number = [1, 2, 3, 4, 5]
arr = np.array(list_of_number)
To get the data inside the array, you can use index to indicate the position of the data. For example, if you run this code
print(arr[2])
it will output
3
And if you run
print(arr[4])
you will get
5
Congratulations! you now know how to access data inside NumPy array using indexing. Thank you for reading this blog, see you next time!
Top comments (0)