title: Comparing a Downloaded String to a List in Python
body: <p>I'm trying to create a sentiment analyser in Python that downloads text and analyses it against a list of negative and positive words. For every match within the text with a word in <em>poswords.txt</em> there should be a <code>+1</code> score and for every match within the text in <em>negwords.txt</em> there should be a <code>-1</code> score, the overall score for the text will be the sentiment score. This is how I have tried to do it but I keep just getting a score of 0.</p>
  
  <p>The answer below does not seem to work, I keep getting a sentiment score of 0.</p>
  
  <pre><code> split = text.split()
      poswords = open('poswords.txt','r')
      for word in split:
          if word in poswords:
              sentimentScore +=1
      poswords.close()
  
      negwords = open('negwords.txt','r')
      for word in split:
          if word in negwords:
              sentimentScore -=1
      negwords.close()
  </code></pre>