title: How can I find and print a string between two strings in python?
body: <p>I was wondering how I can print all the text between a \begin statement and a \end statement. 
  This is my code now. 
  Also, how can I keep from printing certain words located between these 2 statements?</p>
  
  <pre><code>content=open("file", "r")
  print content
  content.read()
  
  while len(content.split(start,1)) &gt; 1:
      start=("\begin")
      end=("\end")
      s=content
      print find_between( s, "\begin", "\end" )
  
  
  def find_between( s, first, last ):
      try:
          start = s.index( first ) + len( first )
          end = s.index( last, start )
          return s[start:end]
       except ValueError:
          return ""
  
  
  
  print find_between( s, "\begin", "\end" )
  </code></pre>