title: counting the word length in a file
body: <p>So my function should open a file and count the word length and give the output. For example,</p>
  
  <p>many('sample.txt')</p>
  
  <p>Words of length 1: 2</p>
  
  <p>Words of length 2: 6</p>
  
  <p>Words of length 3: 7</p>
  
  <p>Words of length 4: 6</p>
  
  <p>My sample.txt file contains:
  This is a test file.  How many words are of length one?
  How many words are of length three?  We should figure it out!
  Can a function do this?</p>
  
  <p>My coding so far,</p>
  
  <pre><code>def many(fname): infile = open(fname,'r')
  text = infile.read()
  infile.close()
  L = text.split()
  L.sort
  for item in L:
      if item == 1:
          print('Words of length 1:', L.count(item))
  </code></pre>
  
  <p>Can anyone tell me what I'm  doing wrong. I call the function nothing happens. It's clearly because of my coding but I don't know where to go from here. Any help would be nice, thanks.</p>