How to select an array element in Python
To select a single element of the array in the Python language, use the slicing technique
a[m]
The variable a is the name of the array.
The parameter m is an integer indicating the position of the element in the array index.
Note. Therefore, the first element of the array is zero in the index.
Example
Import the module Numpy
import numpy as np
Define an array using the function array()
v=np.array(['a','b','c','d','e','f','g'])
To select the first element (n=0)
print(v[0])
The output result is
a
To select the second element (n=1)
print(v[1])
The output result is
b
To extract the third element (n=2)
print(v[2])
The output result is
c
https://how.okpedia.org/en/python/how-to-select-an-array-element-in-python
Report an error or share a suggestion to enhance this page