title: Output dictionary data dynamically from a python for loop
body: <p>here, I am trying to spell check a txt file. first half of my code outputs original (var word) and corrected, if any, (var spell(word)). my replacement code uses a data structure like <code>{'zero':'0', 'temp':'bob', 'garbage':'nothing', 'garnvsh': 'garnish'}</code>. Now I would like to produce the same data structure from the loop dynamically. Can you, please, help me figure it out how to output similar data structure with <code>var word</code> and <code>var spell(word)</code> with first half of the code?</p>
  
  <pre><code>import os, os.path
  from textblob import TextBlob
  from autocorrect import spell
  import fileinput
  import json
  
  data = []
  
  with open("input.txt", "r") as my_file:
      for line in my_file.readlines():
          zen = TextBlob(line)
          for word in zen.words:
              word, spell(word)
  
  replacements = {'zero':'0', 'temp':'bob', 'garbage':'nothing', 'garnvsh': 'garnish'}
  
  with open('../input.txt') as infile, open('../output.txt', 'w') as outfile:
      for line in infile:
          for src, target in replacements.iteritems():
              line = line.replace(src, target)
          outfile.write(line)
  </code></pre>