making index with python
<p>the following is my question:</p>

<pre><code>data = ['a1_1 00000001\n', 'a1_2 00000002\n', 'a1_3 00000003\n',
        'b1_1 00000004\n', 'b1_2 00000005\n', 'b1_3 00000006']

candidate = ['a', 'b']

for i in candidate:
    for j in data:
        if i in j.split()[0]:
            print i, j.split()[1]

a 00000001
a 00000002
a 00000003
b 00000004
b 00000005
b 00000006
</code></pre>

<p>But what I want to do is to make the result like the following:</p>

<pre><code>a 00000001, 00000002, 00000003
b 00000004, 00000005, 00000006
</code></pre>

<p>How do I solve this problem?
Thanks in advance!</p>
