title: How to make an if inside a for-loop run only once?
body: <p>I am trying to put items from two lists together, based on a condition, to create a third list as output. Even though I am a novice, this is relatively straightforward. However, I am trying to make one part of the loop run only once and this where I struggle. Is there a way to do this?</p>
  
  <p>The data comes from a large DataFrame of text data. But I created a simplified version of the problem, to try and solve it more easily (without luck):</p>
  
  <pre><code>a = [1, 2, 3, 4, 5]
  A = [4, 5]
  
  b = []
  for i in a:
      if i in A:
          b.append(3.5) # My aim is to make this line run only once
          b.append(i)
      else:
          b.append(i)
  print(b)
  </code></pre>
  
  <p>This gives:</p>
  
  <pre><code>[1, 2, 3, 3.5, 4, 3.5, 5]
  </code></pre>
  
  <p>How can I get the following result?</p>
  
  <pre><code>[1, 2, 3, 3.5, 4, 5]
  </code></pre>