Taking a quick look at the manual, you will see that np.put
does not return a value. While your technique is fine, you are accessing None
instead of your result array.
For a 1-D array it is better to just use direct indexing, especially for such a simple case.
Here is how to rewrite your code with minimal modification:
arr = np.zeros(10)
np.put(arr, 5, 1)
Here is how to do the second line with indexing instead of put
:
arr[5] = 1