My code should get an array with zero or 1 values, if any element is 0, it should switch it to 1 and also switch the status of its divisors. The problem is that the second if seems not to work and it does not change the 1 status to 0. I don't get why, can anyone help me?
data = input()
L = list(data.split())
L2 = np.array(L,int)
L3 = np.zeros(len(L2),int)
for i in range(len(L2)-1, -1, -1):
if ( L2[i] == 0) :
L2[i] = 1
L3[i] = 1
for j in range(0, i) :
if ((i+1)%(j+1) == 0 & L2[j] == 0) :
L2[j] = 1
if ((i+1)%(j+1) == 0 & L2[j] == 1) :
L2[j] =0 #this does not work
print(*L3)
&is a bitwise operator in python you should useandkeyword in your case.