title: Remove element from list of lists during loop
body: <p>I have a data structure <code>info</code> (a list of lists?) that I am constructing as follows: </p>
  
  <pre><code>pages     = [12, 41, 50, 111, 1021, 121]
  bookCodes = ['M', 'P', 'A', 'C', 'A', 'M']
  sentences = ['THISISASENTENCE',
               'ANDHEREISONEMOREEXAMP',
               'ALLFROMDIFFERENTBOOKS',
               'ANDFROMDIFFERENTPAGES',
               'MOSLTYTHESAMELENGTHS',
               'THISISSHORT'
               ]
  info = list(zip(bookCodes, pages, sentences))
  </code></pre>
  
  <p>I am then iterating over this list (of zipped lists) on letter at a time. As some sentences are shorter than others (e.g. <code>THISISSHORT</code>) I reach the final element before other sentences. In this case I want mask this element from future iterations completely <strong>but I don't want to filter it before I start my loop</strong>.</p>
  
  <pre><code>import random
  
  letters_read = 0
  
  for i in range(21):
      random.shuffle(info)
      for b, p, s in info:
          if len(s) &lt;= i+1:
              print("End of sentence reached at position %s. Sentence: %s" % (i, s))
              continue    
          letters_read += 1
  </code></pre>
  
  <p>I am currently using <code>continue</code> to skip over elements where this is the case, and print a message to indicate the sentence that has reach its end. However, this will continue iterating over this element until the end of the loop. <strong>I want to exclude such elements from further iterations.</strong></p>
  
  <p>I have ~ <code>10,000</code> sentences in my list, and these can be as large as <code>2000</code> characters, so I am assuming that by masking such sentences from future iterations rather than skipping will increase the efficiency of my script. </p>
  
  <p>Is it possible to remove/mask an element from this data structure during iteration? I've tried using <code>info.remove(i)</code> and <code>del info[i]</code>, but this doesn't work (seeing as this is not a list). </p>
  
  <hr>
  
  <p><strong>Output</strong>: </p>
  
  <pre><code>End of sentence reached at position 10. Sentence: THISISSHORT
  End of sentence reached at position 11. Sentence: THISISSHORT
  End of sentence reached at position 12. Sentence: THISISSHORT
  End of sentence reached at position 13. Sentence: THISISSHORT
  End of sentence reached at position 14. Sentence: THISISASENTENCE
  End of sentence reached at position 14. Sentence: THISISSHORT
  End of sentence reached at position 15. Sentence: THISISSHORT
  End of sentence reached at position 15. Sentence: THISISASENTENCE
  End of sentence reached at position 16. Sentence: THISISASENTENCE
  End of sentence reached at position 16. Sentence: THISISSHORT
  End of sentence reached at position 17. Sentence: THISISASENTENCE
  End of sentence reached at position 17. Sentence: THISISSHORT
  End of sentence reached at position 18. Sentence: THISISASENTENCE
  End of sentence reached at position 18. Sentence: THISISSHORT
  End of sentence reached at position 19. Sentence: THISISASENTENCE
  End of sentence reached at position 19. Sentence: MOSLTYTHESAMELENGTHS
  </code></pre>
  
  <p><strong>Desired output</strong>:</p>
  
  <hr>
  
  <pre><code>End of sentence reached at position 10. Sentence: THISISSHORT
  End of sentence reached at position 14. Sentence: THISISASENTENCE
  End of sentence reached at position 19. Sentence: MOSLTYTHESAMELENGTHS
  </code></pre>