In this HackerRank List Comprehensions problem, we have given three integers representing the dimensions of a cuboid and an integer. we need to print a list of all possible coordinates where the sum of the coordinate point is not equal to the n.

HackerRank List Comprehensions in python problem solution

HackerRank List Comprehensions in python problem solution

ans=[]
X=int(input())
Y=int(input())
Z=int(input())
N=int(input())
for i in range (X+1):
    for j in range (Y+1):
        for k in range (Z+1):
            if ((i+j+k)!=N):
                ans.append([i,j,k])
print (ans)
          


Second Solution

X = int(raw_input())
Y = int(raw_input())
Z = int(raw_input())
N = int(raw_input())

lis = [[x,y,z] for x in range(X+1) for y in range(Y+1) for z in range(Z+1)]
print [el for el in lis if sum(el) != N]