You are given three integers x,y,z and representing the dimensions of a cuboid along with an integer n . You have to print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n Here,
0<= i <= x
0<= j <= y
0<= k <= z
My Code:
if __name__ == '__main__':
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:
list_1 = [i,j,k]
list_2 = [list_1]
print(f"{list_2}", end='')
My Output (stdout):
[[0, 0, 0]],[[0, 0, 1]],[[0, 1, 0]],[[1, 0, 0]],[[1, 1, 1]],
Expected Output:
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]
How to deal with that bracket, my logic is correct but just a bit doubt here why my answer is not matching to the expected output.