title: Replacing a list item and returning a copy of the list (in one line) with Python
body: <p>I'm working on something that uses search, so each recursive call needs a separate copy of a list but with a single element replace. I'd like to do it (neatly) in one line, and so far I have this which goes in the recursive call:</p>
  
  <pre><code>[new_value if x == replace_index else my_list[x] for x in range(len(my_list))]
  </code></pre>
  
  <p>But is there a neater way to do this, potentially using some built in function I'm missing?</p>