title: How to loop backwards in python?
body: <p>I'm talking about doing something like:</p>
  
  <pre><code>for(i=n; i&gt;=1; --i) {
     //do something with i
  }
  </code></pre>
  
  <p>I can think of some ways to do so in python (creating a list of <code>range(1,n+1)</code> and reverse it, using <code>while</code> and <code>--i</code>, ...) but I wondered if there's a more elegant way to do it. Is there?</p>
  
  <p>EDIT:
  Some suggested I use xrange() instead of range() since range returns a list while xrange returns an iterator. But in Python 3 (which I happen to use) range() returns an iterator and xrange doesn't exist.</p>