title: for or while loop to do something n times
body: <p>In Python you have two fine ways to repeat some action more than once. One of them is <code>while</code> loop and the other - <code>for</code> loop. So let's have a look on two simple pieces of code:</p>
  
  <pre><code>for i in range(n):
      do_sth()
  </code></pre>
  
  <p>And the other:</p>
  
  <pre><code>i = 0
  while i &lt; n:
      do_sth()
      i += 1
  </code></pre>
  
  <p>My question is which of them is better. Of course, the first one, which is very common in documentation examples and various pieces of code you could find around the Internet, is much more elegant and shorter, but on the other hand it creates a completely useless list of integers just to loop over them. Isn't it a waste of memory, especially as far as big numbers of iterations are concerned?</p>
  
  <p>So what do you think, which way is better?</p>