title: subtracting strings in array of data python
body: <p>I am trying to do the following:</p>
  
  <ol>
  <li>create an array of random data</li>
  <li>create an array of predefined codes (AW, SS)</li>
  <li>subtract all numbers as well as any instance of predefined code. </li>
  <li>if a string called "HL" remains after step 3, remove that as well and take the next alphabet pair. If a string called "HL" is the ONLY string in the array then take that.</li>
  </ol>
  
  <p>I do not know how to go about completing steps 3 - 4. </p>
  
  <h1>1.</h1>
  
  <pre><code>array_data = ['HL22','PG1234-332HL','1334-SF-21HL','HL43--222PG','HL222AW11144RH','HLSSDD','SSDD']
  </code></pre>
  
  <h1>2.</h1>
  
  <pre><code>predefined_code = ['AW','SS']
  </code></pre>
  
  <h1>3.</h1>
  
  <p>ideally, results for this step will look like </p>
  
  <pre><code>result_data = [['HL'],['PG,HL'],['SF','HL'],['HL','PG'],['HL','RH'], 
  ['HL','DD'],['DD']
  </code></pre>
  
  <h1>4. ideally, results for this step will look like this:</h1>
  
  <pre><code>result_data = [['HL'],['PG'],['SF'],['PG'],['RH'], ['DD'],['DD']
  </code></pre>
  
  <p>for step 3, I have tried the following code </p>
  
  <pre><code>not_in_predefined = [item for item in array_data if item not in predefined_code]
  </code></pre>
  
  <p>but this doesnt produce the result im looking for, because it it checking item against item. not a partial string match. </p>