title: Create Dictionary from Text FIle
body: <p>How could I create a dictionary from a text file? I don't want anything special in the text file itself because I would like to write directly to the file from Python. </p>
  
  <p>Text file:</p>
  
  <pre><code>Soda $2 Burger $5 Shake $4 Fries $3
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>file = 'file.dat'
  filer = open(file, "r")
  food = {}
  for i in filer:
      x = i.split(" ")
      for i in range(len(x)):
          if i %2 == 0:
              a = x[i]
          else:
              b = x[i]
          food[a] = b
  </code></pre>