title: How to count the number of words in a paragraph and exclude some words (from a file)?
body: <p>I've just started to learn Python so my question might be a bit silly. I'm trying to create a program that would:
  <br>- import a text file (got it) 
  <br>- count the total number of words (got it), 
  <br>- count the number of words in a specific paragraph, starting with a specific phrase (e.g. "P1", ending with another participant "P2") and exclude these words from my word count. Somehow I ended up with something that counts the number of characters instead :/
  <br>- print paragraphs separately (got it) 
  <br>- exclude "P1" "P2" etc. words from my word count.</p>
  
  <p>My text files look like this:
  <em><br>P1: Bla bla bla.
  <br>P2: Bla bla bla bla.
  <br>P1: Bla bla.
  <br>P3: Bla.</em></p>
  
  <p>I ended up with this code:</p>
  
  <pre><code>text = open (r'C:/data.txt', 'r')
  lines = list(text)
  text.close()
  words_all = 0
  for line in lines:
      words_all = words_all + len(line.split())
  print 'Total words:   ', words_all
  
  words_par = 0
  for words_par in lines:
      if words_par.startswith("P1" or "P2" or "P3") &amp; words_par.endswith("P1" or "P2" or "P3"):
          words_par = line.split()
      print len(words_par)
      print words_par.replace('P1', '') #doesn't display it but still counts
  else:
      print 'No words'
  </code></pre>
  
  <p>Any ideas how to improve it?</p>
  
  <p>Thanks</p>