title: adding elements to list in between indexes while iterating over that list in python
body: <p>I'm trying to iterate over a list of 3D points and create a new point between each group of two points that has a distance larger than a constant value.</p>
  
  <p>I've tried using a buffer unsuccesfully, my main problem is that each newly inserted point needs to respect list order and be inserted between the two points it is between geometrically.</p>
  
  <pre><code>import math
  
  #recieve v1 and maxDist from Blender
  
  buffer = v1
  offset = 0
  
  for i in range(len(v1) - 1):
      p1 = v1[i] 
      p2 = v1[i+1]
  
      if (p1 - p2).length &gt; maxDist :
          middleNode = ((p1.x+p2.x)/2,(p1.y+p2.y)/2,(p1.z+p2.z)/2)
          offset = offset + 1 # 
          buffer.insert(i + offset, middleNode)
  
  v2 = buffer
  
  # send back v2 to Blender
  </code></pre>
  
  <p>the output that I'm having right now ressembles this while a perfectly subdivided circle is expected
  <a href="https://i.stack.imgur.com/dUufI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dUufI.jpg" alt="enter image description here"></a></p>