title: Check if string in strings
body: <p>I have a huge list containing many strings like:</p>
  <pre><code>['xxxx','xx','xy','yy','x',......]
  </code></pre>
  <p>Now I am looking for an efficient way that removes all strings that are present within another string. For example 'xx' 'x' fit in 'xxxx'.</p>
  <p>As the dataset is huge, I was wondering if there is an efficient method for this beside</p>
  <p><code>if a in b:</code></p>
  <p>The complete code: With maybe some optimization parts:</p>
  <pre><code>for x in range(len(taxlistcomplete)):
  if delete == True:
      x = x - 1
      delete = False
  for y in range(len(taxlistcomplete)):
      if taxlistcomplete[x] in taxlistcomplete[y]:
          if x != y:
              print x,y
              print taxlistcomplete[x]
              del taxlistcomplete[x]
              delete = True
              break
      print x, len(taxlistcomplete)
  </code></pre>
  <p>An updated version of the code:</p>
  <pre><code>for x in enumerate(taxlistcomplete):
  if delete == True:
      #If element is removed, I need to step 1 back and continue looping.....
      delete = False
  for y in enumerate(taxlistcomplete):
      if x[1] in y[1]:
          if x[1] != y[1]:
              print x[1],y[1]
              print taxlistcomplete[x]
  
              del taxlistcomplete[x[0]]
              delete = True
              break
  print x, len(taxlistcomplete)
  </code></pre>
  <p>Now implemented with the enumerate, only now I am wondering if this is more efficient and howto implement the delete step so I have less to search in as well.</p>
  <h3></h3>
  <p>Just a short thought...</p>
  <p>Basically what I would like to see...</p>
  <p>if element does not match any other elements in list write this one to a file.
  Thus if 'xxxxx' not in 'xx','xy','wfirfj',etc... print/save</p>
  <p>A new simple version as I dont think I can optimize it much further anyway...</p>
  <pre><code>print 'comparison'
  
  file = open('output.txt','a')
  
  for x in enumerate(taxlistcomplete):
      delete = False
      for y in enumerate(taxlistcomplete):
          if x[1] in y[1]:
              if x[1] != y[1]:
                  taxlistcomplete[x[0]] = ''
                  delete = True
                  break
      if delete == False:
          file.write(str(x))
  </code></pre>