Ignoring a value in a list search
<p>I am using lists to store attributes and this problem cropped up when I was searching for equal items:</p>

<pre><code>l = [['a',1,2],['b',1,2],['c',2,3],['d',1,2]]
if [any,1,2] in l:
    print ('blue')
elif [any,2,3] in l:
    print('red')
</code></pre>

<p>desired output</p>

<pre><code>blue
</code></pre>

<p>What I want is the first value being ignored/can be any value.
I know the any function doesn't work this way but what is the correct method to doing so?</p>

<p>Perhaps this is more understandable</p>

<pre><code>l = [['a',1,2],['b',1,2],['c',2,3],['d',1,2]]
for a in range(0,4):
    if [1,2] == x[1:] for x in l:
        print ('blue')
    elif [2,3] == x[1:] for x in l:
        print('red')
</code></pre>

<p>For filtering equal items (according to your definition) you can use list comprehension and slicing:</p>

<pre><code>&gt;&gt;&gt; lst = [['a',1,2],['b',1,2],['c',2,3],['d',1,2]]
&gt;&gt;&gt; [e for e in lst if e[1:] == [1,2]]
[['a', 1, 2], ['b', 1, 2], ['d', 1, 2]]
</code></pre>

python list