title: Count number of words in a file using dictionary comprehension - python
body: <p>In the following code using dictionary comprehension am trying to count the total number of words with duplicates but this results in <code>{'count': 1, 'words.As': 1, 'said': 1, 'file.\n': 1, 'this': 1, 'text': 1, 'is': 1, 'of': 1, 'some': 1, ',i': 1, 'to': 1, 'only': 1, 'Hi': 1, 'a': 1, 'file': 1, 'recognize': 1, 'test': 1, 'the': 1, 'repeat': 1, 'before': 1}
  </code></p>
  
  <p>I do not see <code>is</code> twice or any of them for the matter what am i doing wrong here?</p>
  
  <p>test_readme.txt</p>
  
  <p><code>Hi this is some text to recognize the count of words.As said before this is only a test file ,i repeat test file.</code></p>
  
  <pre><code>with open('test_readme.txt') as f:
     di = { w : di[w]+1 if w in di else 1  for l in f for w in l.split(' ')}
  print di
  </code></pre>