title: Replacing list elements that satisfy some condition with items from another list in Python
body: <p>Suppose I have those two lists  </p>
  
  <pre><code>a=[0,1,6,4,2,8] 
  b=[10,20,30,40]
  </code></pre>
  
  <p>I want to replace elements in list a that are between 0 and 4 with items from list b.</p>
  
  <p>In other words, my output should be </p>
  
  <pre><code>[10,20,6,30,40,8]
  </code></pre>
  
  <p>Note that essentially, we <em>strip</em> list <code>a</code> of elements satisfying a certain condition and simply replacing it with an item from list b onto this. (The ordering in b is maintained)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I actually know that exactly N number of items in list <code>a</code> satisfy the condition imposed. Then I need to "replace" these in-place with another list b of size N.</p>