title: How to auto alter the code snippets in a file while executing the same file in runtime?
body: <p>I have an sample.py as below</p>
  <pre><code>a = [1, 2, 3]         
  b = 4                                                                                                                                
  a.append(b)
  print(a)
  </code></pre>
  <p>In the above code I am good to extend the array by appending 'b' to 'a'. Now the List 'a' prints</p>
  <pre><code>[1, 2, 3, 4]
  </code></pre>
  <p>This value is going to last only till the time the code executes.
  If I rerun the code, the values will reintialise.</p>
  <p>So, How to replace the snippet
  &quot;
  a = [1, 2, 3]
  with a = [1, 2, 3, 4]
  &quot; by alternatively changing the file itself, so that next time I open the file I see &quot;a = [1,2,3,4] appear in it. Also when we rerun it again, we must get &quot;a&quot; printed as &quot;[1, 2, 3, 4, 4]&quot;</p>