title: Add pair of keys and values to dict
body: <p><a href="https://i.stack.imgur.com/31XvJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/31XvJ.png" alt="enter image description here"></a></p>
  
  <p>I'm trying to format the input format above into a list of dicts. </p>
  
  <p>Basically what I want is to convert the contents of the file into a list of dicts. However, everytime I run the code I get the same output: [{'Similar: similar5, 'Score' : score5, 'Compound': smi}]. Which means only one dict was created, when my objective is to create 5 dicts (one for each line).
  Can somebody help me fix this?</p>
  
  <pre><code>dt = [] # Creates a list to store dicts
  with open('sample_text.out') as f: # Opens the target text file
      for line in f:
  
          if line.startswith('Compound'):
              smi = line.split()[1]
              dt.append({'Compound' : smi}) # Add smi as a value in a dict inside the list 'dt'
  
          else: # This part will iterate over the next few lines, split them and add them to the growing list of dicts
  
              new_line = line.split()
              similar = new_line[0]
              score = new_line[1]
              print new_line
              for dicts in dt:
                  dicts['Similar'] = similar
                  dicts['Score'] = score
  
  
  print dt
  </code></pre>