from itertools import product
[list(i) for i in product(list(range(X + 1)), list(range(Y + 1)), list(range(Z + 1))) if sum(
    i) != N]
Find the coordinates of a cuboid using list comprehension in Python