My code is:
x=np.linspace(1,5,5)
a=np.insert(x,np.arange(1,5,1),np.zeros(3))
The output I want is:
[1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5]
The error I get is:
ValueError: shape mismatch: value array of shape (3,) could not be broadcast to indexing result of shape (4,)
When I do:
x=np.linspace(1,5,5)
a=np.insert(x,np.arange(1,5,1),0)
The out is:
array([1., 0., 2., 0., 3., 0., 4., 0., 5.])
Why it doesn't work when I try to insert an array?
P.S. I I cannot use loops