An n-dimensional array has 2n sides (a 1-dimensional array has 2 endpoints; a 2-dimensional array has 4 sides or edges; a 3-dimensional array has 6 2-dimensional faces; a 4-dime
Here's how you can do it:
assert(all(np.all(np.take(x, index, axis=axis) == 0) for axis in range(x.ndim) for index in (0, -1)))
np.take does the same thing as "fancy" indexing.