I am a learner , bit stuck not getting how do i print the even indexed value of an array
My code :
import numpy as np
arr_1 = np.array([2,4,6,11])
arr_1 [ (arr_1[ i for i in range(arr_1.size) ] ) % 2 == 0 ]
Expected Output :
2,6
2 -> comes under index 0
6 -> comes under index 2
Both are even index
>Solution :
May be this could work for you
Code :
import numpy as np
arr_1 = np.array([2,4,6,11])
a = [ arr_1[i] for i in range(arr_1.size) if ((i % 2) == 0) ]
print(a)
Code is run in google Colab