Search for a partial string in an array of strings
<p>What is the Pythonic/quick way to search for a partial string in an array and then remove that string from the array?<br>
(I can do it with a simple loop and IF IN and rebuild two array in the loop, Asking if there is a Pythonic way/function to do this)</p>

<p>Example:  </p>

<pre><code>array = ['rule1','rule2','exception[type_a]','rule3','exception[type_b]']
res(,)=remove_exceptions(array,'exception')
print(res[0]) &gt;&gt;&gt; ['rule1','rule2','rule3']
print(res[1]) &gt;&gt;&gt; ['exception[type_a]','exception[type_b]']
</code></pre>

<p>You may use in-built <code>filter</code> with <code>lambda</code> function to achieve this as:</p>

<pre><code>&gt;&gt;&gt; my_array = array = ['rule1','rule2','exception[type_a]','rule3','exception[type_b]']
&gt;&gt;&gt; my_string = 'exception'
&gt;&gt;&gt; filter(lambda x: my_string not in x, my_array)
['rule1', 'rule2', 'rule3']
</code></pre>

python arrays python-3.x