So let's say I have a numpy array a= np.array([1,2,3,4,5]) and a value x=4, then I want to create a numpy array of values -1 and 1 where there is a 1 in the 4th position and -1 everywhere else.
Here is what I tried:
for i in range(a):
if i == x:
a[i]=1
else:
a[i]=-1
Is this good?
range(a)doesn't work in your example. It would need to berange(len(a))