title: How to iterate through sentence of string in Python?
body: <p>Assume I have a string <code>text = "A compiler translates code from a source language"</code>. I want to do two things:</p>
  
  <ol>
  <li><p>I need to iterate through each word and stem using the <code>NLTK</code> library. The function for stemming is <code>PorterStemmer().stem_word(word)</code>. We have to pass the argument 'word'. How can I stem each word and get back the stemmed sentence?</p></li>
  <li><p>I need to remove certain stop words from the <code>text</code> string. The list containing the stop words is stored in a text file (space separated)</p>
  
  <pre><code>stopwordsfile = open('c:/stopwordlist.txt','r+')
  stopwordslist=stopwordsfile.read()
  </code></pre>
  
  <p>How can I remove those stop words from <code>text</code> and get a cleaned new string?</p></li>
  </ol>