Dictionary assigning : <pre><code>listim=[['1' ,'2'], ['3' , '4'], ['1', '5'], ['4', '1']]
</code></pre>

<p>I am trying to make dictionary using listim for each number,</p>

<p>I want to have d={'1': 2 , 4, 5 ,'2':1, '3': 4, (...and so on)}</p>

<p>my code is(I can't find the mistake but probably about dictionaries):</p>

<pre><code>a=1
dic={}
while a&lt;6:
    for number in listim:
        if number[0]==a:
            if number[1] not in dic[a]:
                dic[a].append(number[1])
        elif number[1]==a:
            if number[0] not in dic[a]:
                dic[a].append(number[0])
        a+=1
</code></pre>

<p>I couldn't find enough information on web,(I know I can). I hope I was clear enough. Thank you</p>
