printing corresponding item in list to another list containing numbers
<p>My problem is this. 
These are the two lists</p>

<pre><code>codes = ['a', 'b', 'c', 'a', 'e', 'f', 'g', 'a', 'i', 'j', 'a', 'l']
pas = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
</code></pre>

<p>How would I find the position of all the 'a' in the codes list. And then print out the corresponding item in the pas list.
This is what the output should be. They should also be sorted with the .sort() function. </p>

<pre><code>1
4
8
11
</code></pre>

<p>I have come up with this code. (That doesnt work)</p>

<pre><code>qwer = [i for i,x in enumerate(codes) if x == common]
qwe = [qwer[i:i+1] for i in range(0, len(qwer), 1)] 
print(pas[qwe])
</code></pre>

<p>What would be the best way to get the correct output?</p>

<pre><code>&gt;&gt;&gt; pas = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
&gt;&gt;&gt; codes = ['a', 'b', 'c', 'a', 'e', 'f', 'g', 'a', 'i', 'j', 'a', 'l']
&gt;&gt;&gt; result = sorted(i for i,j in zip(pas,codes) if j=='a')
&gt;&gt;&gt; for i in result:
...     print i
... 
1
4
8
11
</code></pre>

python list