I think I found the answer:
as @tuxcanfly said I changed x to a. I also deleted the for loop, because for some reason it deleted the line with index 2.
Instead, now I just decided to delete the rows with b as the delete function using the items in the list to delete the row with this index.
new code:
import numpy as np a=np.array(([7,1,2,8],[4,0,3,2],[5,8,3,6],[4,3,2,0])) b=[] for i in range(len(a)): for j in range (len(a[i])): if a[i][j]==0: b.append(i) print 'b=',b for zero_row in b: a=np.delete(a,b, 0) print 'a=',a
and conclusion:
b= [1, 3] a= [[7 1 2 8] [5 8 3 6]]
source share