title: Python - While-Loop until list is empty
body: <p>I'm working with Django and I have a queryset of objects that has been converted to a list (<code>unpaid_sales</code>). I'm executing a process that iterates through this list and operates on each item until either the list is empty, or a given integer (<code>bucket</code>) reaches zero.</p>
  
  <p>This is how I set it up:</p>
  
  <pre><code>while unpaid_sales:
      while bucket &gt; 0:
          unpaid_sale = unpaid_sales.pop(0)
          ...do stuff
  </code></pre>
  
  <p>In some cases, I am getting the following error: </p>
  
  <blockquote>
    <p>pop from empty list</p>
  </blockquote>
  
  <p>What's wrong with my logic?</p>