title: How can random.shuffle result in a KeyError?
body: <p>I just got the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./download_documents.py", line 153, in &lt;module&gt;
      paragraphs, used_pages = find_pages(lang, to_extract)
    File "./download_documents.py", line 67, in find_pages
      random.shuffle(page_titles_queue)
    File "/usr/lib/python2.7/random.py", line 291, in shuffle
      x[i], x[j] = x[j], x[i]
  KeyError: 1
  </code></pre>
  
  <p>Which confuses me quite a bit.</p>
  
  <ol>
  <li><code>random.shuffle</code> seems to work on zero-element lists and on one-element lists.</li>
  <li><code>page_titles_queue</code> is a list of tuples.</li>
  <li>Two lines <em>after</em> the <code>random.shuffle(page_titles_queue)</code>, there is <code>page_titles_queue.pop()</code>, but that should not affect the shuffle. Right?</li>
  </ol>
  
  <p>So what are possible reasons for the KeyError?</p>
  
  <p>I use <code>Python 2.7.12</code> on Ubuntu 16.04.</p>