Check if multiple lists contain multiple items
<p>I have a list of lists in my python code, and I want to check if <em>any</em> of those lists contains a certain two items.</p>

<pre><code>f1=['a','b']
f2=['c','d']
f3=['e','f']
f4=['g','h']
f5=['i','j']
f6=['k','l']

flist=[f1,f2,f3,f4,f5,f6]
</code></pre>

<p>I want something like:</p>

<pre><code>if 'a' in flist[0:5] and 'b' in flist[flist.index('a')]:
   print (true)
</code></pre>

<p>What's the easiest way to do this?</p>

<p>How about you just iterate over it.</p>

<pre><code>for i in range(len(flist)):
  if ['a', 'b'] == sorted(flist[i]):
    print (i)
</code></pre>

<p>or you can simply do one-liner, just to know if it exists.</p>

<pre><code>print (["a", "b"] in [sorted(x) for x in flist])
</code></pre>

python list