title: Python : How to set a condition to 'ignore' some code if this condition is met?
body: <p>I am using Python (I think it's version 2.7)</p>
  
  <p>I have a section of code here, which is part of a function that takes x_1,x_2 and x_f (same for y) as inputs and colours in corresponding pixels in an image (x_f and y_f denote the final pixels in the image, so that it is only drawing within the image bounds.</p>
  
  <pre><code>while x_1+k*x_2&lt;=x_f and y_1+k*y_2&lt;=y_f:
      pixels[x_1+k*x_2,y_2+k*y_2]=colour
      k+=1
  </code></pre>
  
  <p>The issue I have is, I require this code to take an input <code>x_f (or y_f) = Empty</code></p>
  
  <p>If <code>x_f=Empty</code>, the above piece of code should ignore the entire x section in the first line and produce an output based only on y values like this:</p>
  
  <pre><code>while y_1+k*y_2&lt;=y_f:
      pixels[x_1+k*x_2,y_2+k*y_2]=colour
      k+=1
  </code></pre>
  
  <p>and visa-versa. Unfortunately, I can't work out how to get it to do this. </p>
  
  <p>My attempts included: </p>
  
  <pre><code>if x_f is not Empty and y_f is not Empty: 
      while x_1+k*x_2&lt;=x_f and y_1+k*y_2&lt;=y_f:
          pixels[x_1+k*x_2,y_2+k*y_2]=colour
          k+=1
  else:
      if x_f==Empty:
          while y_1+k*y_2&lt;=y_f:
             pixels[x_1+k*x_2,y_2+k*y_2]=colour
             k+=1
      else:
          while x_1+k*x_2&lt;=x_f:
             pixels[x_1+k*x_2,y_2+k*y_2]=colour
             k+=1  
  </code></pre>
  
  <p>The issue with that isn't that it throws up an error, but rather that the program I have to run my code on won't allow me to run this - it crashes and gives me a CPU error. Does anyone have any ideas?</p>
  
  <p>Thank you.</p>
  
  <p><strong>Edit~</strong>
  I am using a function colour_pixels(x_1,x_2...y_f) to take my input.</p>
  
  <p>My error is: "IVLE console restarted: Communication lost"</p>
  
  <p>When inputting value y_f is inputted as "Empty"</p>
  
  <p>I have to be able to take cases where either x_f or y_f could be 'Empty' - apologies, I didn't explain that very well</p>
  
  <p>Thank you - I will change '!=' to 'is not' now!</p>