compare string list in python
<p>I wrote a code in python but I am not sure why it never get match while it should be able, would you mind check what is the issue in my code?</p>

<p>my assumption is my select query creating list of list "('bad'  <strong>,</strong>   ), ('worse'   <strong>,</strong>   ),   but I am not sure how to remove it " <strong>,</strong>" </p>

<p>I am using visual studio and python 3.5:</p>

<pre><code> if len(list(set(words) &amp; set(badlst))) &gt; 0:
        index +=1
</code></pre>

<blockquote>
  <p>words :(data details) ['term', 'saving', 'insurance', 'cost', '?',
  'upgrade', 'plan', 'always', 'preferred', 'client', ',', 'bad',
  'agent', 'explained', ...]</p>
  
  <p>badlst : (data details)  [('bad',), ('worse',), ('incorrigible',),
  ('poor',), ('dreadful',), ('atrocious',), ('cheap',),
  ('unacceptable',), ('sad',), ('lousy',), ('crummy',), ('awful',),
  ('rough',), ('synthetic',), ...]</p>
</blockquote>

<p>I generate badlst as below:</p>

<pre><code>def readInsCmp(column, tablename, whereCondition):
    command = "select "+ column+" from "+ tablename +" where "+ whereCondition 
    c.execute(command)
    namelist = c.fetchall()
    return namelist

badlst = readInsCmp("distinct(word)","wordVals","value=-1")
</code></pre>

<p>Words parameter is based on parse some input from excel file:</p>

<pre><code>sentenceArr = sent_tokenize(content)
for sentence in sentenceArr:
 words = [word for word in nltk.word_tokenize(sentence) if word not in stopwords.words('english')]
</code></pre>