title: how to use iterator in while loop statement in python
body: <p>Is it possible to use a generator or iterator in a while loop in Python? For example, something like:</p>
  
  <pre><code>i = iter(range(10))
  while next(i):
      # your code
  </code></pre>
  
  <p>The point of this would be to build iteration into the while loop statement, making it similar to a for loop, with the difference being that you can now additional logic into the while statement:</p>
  
  <pre><code>i = iter(range(10))
  while next(i) and {some other logic}:
      # your code
  </code></pre>
  
  <p>It then becomes a nice for loop/while loop hybrid.</p>
  
  <p>Does anyone know how to do this?</p>