python link values dictionary 1 to keys dictionary 2
<p>I have two dictionaries. I have to match the values in the first to the keys in the second and then return the value found in the second dictionary. I came up with this so far:</p>

<pre><code>d1 = {}
with open ("file1.txt") as f:
   for line in f:
       (key,val) = line.split()
       d[int(key)] = val
d2 = {}
with open("file2.txt") as f:
   for line in f:
      (key,val) = line.split()
      d[int(key)] = val

for item in d1.values():
     if d2.has_key(item):
         print value.d2(item)
</code></pre>

<p>I keep getting the error "too many values to unpack" and aside from that, would my script actually do what I want it to do?</p>

<p>UPDATE (Sorry didn't know I could edit my question!):
I my two text files, file1 maps a word to a number system, and file2 maps the number to its relevant category. The end result should be that the word of file1 is linked to its category which is found in file2. This is done by first linking the word to a number and then linking the number to a category. For example: Aanbidden (dutch word) > 12 > Cat. "affect". The lines in my file look like this:</p>

<p>file1.txt:</p>

<pre><code>aanbidden: 12 13 14 57 58  
leven : 15
drinken: 23 56 
... 
(As you see each key can have one or more values)
</code></pre>

<p>file2.txt:</p>

<pre><code>12: affect
13: posemo
14: Posfeel
15: Optim
23: discrep
56: money
57: metaph
58: religious
...
(In this file each key has only one value)
</code></pre>
