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
maybe the ellipsis operator is what you are looking for, which will work for many dimensions:
import numpy as np
# data
x = np.random.rand(2, 5, 5)
x[..., 0:, 0] = 0
x[..., 0, 0:] = 0
x[..., 0:, -1] = 0
x[..., -1, 0:] = 0
test = np.all(
[
np.all(x[..., 0:, 0] == 0),
np.all(x[..., 0, 0:] == 0),
np.all(x[..., 0:, -1] == 0),
np.all(x[..., -1, 0:] == 0),
]
)
print(test)