title: Why can't I iterate twice over the same data?
body: <p>Why can't I iterate twice over the same <a href="https://docs.python.org/3/glossary.html#term-iterator" rel="noreferrer">iterator</a>?</p>
  <pre><code># data is an iterator.
  
  for row in data:
      print(&quot;doing this one time&quot;)
  
  for row in data:
      print(&quot;doing this two times&quot;)
  </code></pre>
  <p>This prints <code>&quot;doing this one time&quot;</code> a few times, since <code>data</code> is non-empty. However, it does <em>not</em> print <code>&quot;doing this two times&quot;</code>. Why does iterating over <code>data</code> work the first time, but not the second time?</p>