Numpy practice question (no. 3)

Screen Link:
https://app.dataquest.io/m/1023/numpy-index-selection-practice-problems/3/selecting-odd-indexes

My Code:

import numpy as np
values = [7, 4, 5, 8, 9, 0, 1, 3, 2, 6]
x = np.array(values)
odd = x[1::2]
print(odd)

What I expected to happen:
The odd indexes of an array are 1, 3, 5, 7, and so on

What actually happened:

Output
[4 8 0 3 6]

Why the output not all odd numbers?

1 Like

Hi @samantha,

Your code extracted the values of the items of your array corresponding to those indices, not the indices themselves. So the value 4 has the index 1, the value 8 - the index 3, etc.

1 Like