title: List comprehension in python with multiple loops and if statements
body: <p>I have to print a list of ordered pairs where x+y+z != n. The code doesn't seem to be working</p>
  
  <pre><code>def main():
      x = int(input())
      y = int(input())
      z = int(input())
      n = int(input())
      result = [[i,j,k] for i in range(0,x+1) for j in range(0,y+1) for k in range(0,z+1) if (x+y+z) != n]
      print(result)
  </code></pre>
  
  <p>Input:</p>
  
  <pre><code>1
  1
  1
  2
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
  </code></pre>
  
  <p>I shouldn't be getting the ordered pairs [0,1,1] , [1,0,1], [1,1,0].</p>
  
  <p>Please correct me.</p>
  
  <p>Thanks in advance!</p>