Python: Using list comprehensions to filter a list by a list of substrings
<p>I think this is a simple question, so I'll just go straight to an example.</p>

<p>Given these two lists:</p>

<pre><code>x = ['a', 'ab', 'abc', 'bc', 'c', 'ac']
y = ['a', 'b']
</code></pre>

<p>How do I write a list comprehension to filter list x in such a way that the result would be:</p>

<pre><code>result = ['c']
</code></pre>

<p>I want a list comprehension that excludes any partial matches of the strings in y to the strings in x.  For example, 'a' in y would match 'a', 'ab', 'abc', and 'ac' in x.</p>

<p>This comprehension only matches entire strings: <code>result = [r for r in x if r not in y]</code></p>

<p>If this has already been asked I'll gladly accept a link to a previous answer.  That said, I haven't found one on SO yet.</p>