title: How to make a for loop either increasing or decreasing?
body: <p>I have to loop between two values where sometimes the first value is less than the second, and some other times the first is greater than the second (I'm working on two cells inside a grid and the first cell can be on the left of the second or vice versa).</p>
  <p>With Python, I can specify if a for loop has to decrease or to increase its values, but the result is something like that:</p>
  <pre><code>step = 1
  if y &lt; x:
      step = -1
  for n in range(x, y, step):
      pass
  </code></pre>
  <p>Is there something more <em>&quot;pythonic&quot;</em> to obtain this?</p>