title: How do I match items in one list against items in another list in Python
body: <p>Having trouble finding a python solution to matching elements of one list against elements in another list without a whole pile of "for" and "if" loops. I'm hoping to find a better way to do this. I have some big iterating loops that go through multiple lists to perform matches. On a match, I want elements of the list removed. Here are two examples:</p>
  
  <pre><code>def score_and_retweet(auth):
      api = tweepy.API(auth)
      for tweet in api.home_timeline(count=100, include_rts=0):
          for goodword in tweet_whitelist:
              if goodword in tweet.text and tweet.retweet_count &gt;= 2:
                  try:
                      api.retweet(tweet.id_str)
                  except tweepy.error.TweepError:
                      error_id = tweet.id_str
  </code></pre>
  
  <p>and</p>
  
  <pre><code>t = time.localtime()
      if t.tm_hour is 14 and (t.tm_wday is 1 or t.tm_wday is 4):
          htmlfiles = glob.glob(html_file_dir+'/*.html')
          for file in htmlfiles:
              for badword in filename_badwords:
                  if badword in file:
                      try:
                          htmlfiles.remove(file)
                      except ValueError:
                          error = "already removed"
  </code></pre>