I am searching a rather large matrix for zero elements and then want to then loop over the rows and inside each row, over all the indices where I found a zero. numpy.where(M==0)