title: How to get the words before and after a specific word from a textfile
body: <p>I defined this function to find the keywords in a text file but, now i want to get a tuple containing the words before and after the key word in the file and i am not sure of how to do that</p>
  
  <pre><code>def findProperWords(paragraphs, excludedWords):
  key = [] # an empty list
  count = 0
  for paragraph in paragraphs:  #calling of every paaragraph in the textfile
      count += 1 #counting each paragraph
      words = list(paragraph.split(' ')) 
             # spliting each paragraph into a list of words
      for keys in words: 
          if len(keys) &gt; 0:
              if keys[0] == keys[0].upper(): 
                           #checking for words that start with capital letters
                  if keys.lower() not in excludedWords: 
                       key.append(keys) # creating a list of the key words
                         index = paragraph.find(keys) 
                          # finding the position of each key word in the textile
  </code></pre>