title: Replacing a character on a string
body: <p>Sorry if this has been asked before, I looked and couldn't find it.</p>
  
  <p>I've been asked to make a algorithm that changes a character on a string. Here is an example:</p>
  
  <p>a b c</p>
  
  <p>d e f</p>
  
  <p>I want to chance every 'a' to 'd', every 'd' to 'a', every 'b' to 'e', every 'e' to 'b' and so on. So if my input is "abc def", my output is "def abc".</p>
  
  <p>I tried:</p>
  
  <pre><code>def change(string, dic):
      for i, c in dic.iteritems():
          string = string.replace(i, c)
      return string
  
  dic = {'a':'d','b':'e','c':'f',
         'd':'a','e':'b','f':'c'}
  
  string = 'abc def'
  
  print change(string,dic) #returns abc abc
  </code></pre>
  
  <p>I didn't think python would check twice each character on the string (if this is what happened). </p>
  
  <p>everything I tried didn't work, can you guys give me some advice?</p>
  
  <p>Thanks.</p>