Something like :
np.array([int(i == 5) for i in range(10)])
Should do the trick.
But I suppose there exist other solutions using numpy.
edit : the reason why your formula does not work : np.put does not return anything, it just modifies the element given in first parameter. The good answer while using np.put()
is :
a = np.zeros(10)
np.put(a,5,1)
The problem is that it can't be done in one line, as you need to define the array before passing it to np.put()