title: Finding maximum and minimum number of words among the sentences in the input file
body: <p><strong>I have a question that ask me to find min and max number of the words in the text file. I've finished three of five questions and two left are asking for min and max values which I can not have any solution for that. Here's my code: thanks for your help</strong></p>
  
  <pre><code>lines, blanklines, sentences, words  = 0, 0, 0, 0,
  print '-' * 50
  full_text = 'input.txt'
  empty_text = 'output.txt'
  
  text_file = open(full_text, 'r')
  out_file = open(empty_text, "w")
  
  
  for line in text_file:
    print line
    lines += 1
  
    if line.startswith('\n'):
      blanklines += 1
    else:
      # assume that each sentence ends with . or ! or ?
  
      # so simply count these characters
  
      sentences += line.count('.') + line.count('!') + line.count('?')
  
  
      # create a list of words
  
      # use None to split at any whitespace regardless of length
  
      # so for instance double space counts as one space
  
      # word total count
  
      words += len(line.split())
  average = float(words) / float(sentences)
  
  
  
  text_file.close()
  out_file.close()
  
  ######## T E S T   P R O G R A M ########
  
  print
  print '-' * 50
  print "Total number of sentences in the input file  : ", sentences
  print "Total number of words in the input file      : ", words
  print "Average number of words per sentence         : ", average
  </code></pre>