How to match every word in the list having single sentence using python
<p>how to match the below case 1 in python.. i want each and every word in the sentence to be matched with the list. </p>

<pre><code>l1=['there is a list of contents available in the fields']
&gt;&gt;&gt; 'there' in l1
False
&gt;&gt;&gt; 'there is a list of contents available in the fields' in l1
True
</code></pre>

<p>If you just want to know if any of the string in the list contains a word no matter which string it is you can do this:</p>

<pre><code>if any('there' in element for element in li):
    pass
</code></pre>

<p>Now if you want to filter the ones which matches the string you can simply:</p>

<pre><code>li = filter(lambda x: 'there' in x, li)
</code></pre>

<p>Or in Python 3:</p>

<pre><code>li = list(filter(lambda x: 'there' in x, li))
</code></pre>

python