title: How to simultaneously edit values in a list?
body: <p>The user inputs 2 different integers, the program then searches for the numbers in the list and replaces the first number with the second number, displays the new list and this process continues.</p>
  <p>Explanation:</p>
  <p><code>[0,1,2,3,4,5,6,7,8,9]</code></p>
  <p>1st input -&gt; 2
  <br>
  2nd input -&gt; 3</p>
  <p>new list <code>[0,1,3,3,4,5,6,7,8,9]</code></p>
  <p>1st input -&gt; 3
  <br>
  2nd input -&gt; 4</p>
  <p>new list2 <code>[0,1,4,4,4,5,6,7,8,9]</code></p>
  <p>Here is my approach:</p>
  <pre><code>b=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  while True:
      print(b)
      a1 = int(input(&quot;Enter a nmuber:&quot;))
      a2 = int(input(&quot;Enter a number:&quot;))
      for i in b:
          if i == (a1):
              b[i] = a2
      print(b)
  </code></pre>
  <p>This successfully changes the 1st values , but when I am trying to input 3 and 4, the program only changes one of the 3's in the list , below is the output, 1st iteration input-&gt;2 and 3 , 2nd input -&gt; 3 and 4</p>
  <p>output:</p>
  <pre><code>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  Enter a nmuber:2
  Enter a number:3
  [0, 1, 3, 3, 4, 5, 6, 7, 8, 9]
  [0, 1, 3, 3, 4, 5, 6, 7, 8, 9]
  Enter a nmuber:3
  Enter a number:4
  [0, 1, 3, 4, 4, 5, 6, 7, 8, 9]
  [0, 1, 3, 4, 4, 5, 6, 7, 8, 9]
  Enter a nmuber:
  </code></pre>
  <p>Why isn't the program changing the values according to my needs in the second (and upcoming) iterations?</p>