title: Build dictionary from file and os.listdir python
body: <p>I'm using os.listdir and a file to create a dictionary. I'm getting keys and values from them respectively.</p>
  
  <p>os.listdir gives me:</p>
  
  <pre><code>EVENT3180
  EVENT2894
  EVENT2996
  </code></pre>
  
  <p>and from the file I get:</p>
  
  <pre><code>3.1253   -32.8828   138.2464
  11.2087   -33.2371   138.3230
  15.8663   -33.1403   138.3051
  </code></pre>
  
  <p>The main problem is that my final dictionary has different keys but always the same value which is not what I want. What I'm trying to get is:</p>
  
  <pre><code>{'EVENT3180': 3.1253   -32.8828   138.2464, 'EVENT2894': 11.2087   -33.2371   138.3230, 'EVENT2996': 15.8663   -33.1403   138.3051}
  </code></pre>
  
  <p>So I think my code is looping over the keys but not over the values. Anyway, my code so far:</p>
  
  <pre><code>def reloc_event_coords_dic ():
      event_list = os.listdir('/Users/working_directory/observed_arrivals_loc3d')
      adict = {}
      os.chdir(path) # declared somewhere else
      with open ('reloc_coord_complete', 'r') as coords_file:
          for line in coords_file:
              line = line.strip() #Gives me the values
              for name in event_list: # name is the key
                  entry = adict.get (name, [])
                  entry.append (line)
                  adict [name] = entry
              return adict
  </code></pre>
  
  <p>Thanks for reading!</p>