title: Duplicate iteration in for loop
body: <p>I am having 3 docx in a directory. <code>abcd.docx</code>, <code>uvwx.docx</code>, <code>qwer.docx</code>. I am iterating through these files. Here I am getting an additional iteration in which the last iteration prints <code>er.docx</code>. i.e. it skips the first two characters and prints the rest of last file. Below is the code and output.</p>
  
  <pre><code>for filename in os.listdir(directory):
      if filename.endswith(".docx"): 
          print(os.path.join(directory, filename))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>filepath\abcd.docx     
  filepath\uvwx.docx
  filepath\qwer.docx
  filepath\er.docx                       
  </code></pre>
  
  <p>Why this last iteration happens?</p>