title: How exactly does Python's .replace() works?
body: <p>I was trying to replace two different characters <code>@</code> and <code>.</code> in a string with one character <code>|</code> . When I assign the replacing variable to the same variable, the replacing of <code>@</code> and <code>.</code> to <code>|</code> works, but using different variable, it only replace dot to <code>|</code>. May I know what's the reason causing the difference?</p>
  <p>Using same variable:</p>
  <pre><code>email = input(&quot;Please enter your email address : &quot;)
  for x in ('@','.'):
       email = email.replace(x,'|')
  print(email)
  </code></pre>
  <p>Output:</p>
  <pre><code>Please enter your email address : sdf@sadfs.com
  sdf|sadfs|com
  </code></pre>
  <p>Using other variable:</p>
  <pre><code>email = input(&quot;Please enter your email address : &quot;)
  for x in ('@','.'):
       temp_email = email.replace(x,'|')
  print(temp_email)
  </code></pre>
  <p>Output:</p>
  <pre><code>Please enter your email address : sdf@sadfs.com
  sdf@sadfs|com
  </code></pre>