title: Pythonic way to search a list using keywords
body: <p>I am attempting to search for text between two keywords. My solution so far is using <code>split()</code> to change string to list. It works but I was wondering if there is more efficient/elegant way to achieve this. Below is my code:</p>
  
  <pre><code>words = "Your meeting with Dr Green at 8pm"
  list_words = words.split()
  before = "with"
  after = "at"
  title = list_words[list_words.index(before) + 1]
  name = list_words[list_words.index(after) - 1]
  
  
  if title != name:
      var = title + " " + name
      print(var)
  else:
      print(title)
  </code></pre>
  
  <p>Results: </p>
  
  <pre><code>&gt;&gt;&gt; Dr Green
  </code></pre>
  
  <p>Id prefer a solution that is configurable as the text I'm searching for can be dynamic so Dr Green could be replaced by a name with 4 words or 1 word. </p>