title: Access previous list element in for loop without range() or enumerate()
body: <p>I want to rewrite this code, so it won't use the <code>range()</code> function. I've had a search around, but it only suggests using <code>enumerate()</code> in its place. But I'd like for it to be done as a regular <code>for</code> loop, even if it's a more difficult or complex way, so I can understand how and why the <code>range()</code> function simplifies the code.</p>
  <p>What I've written so far:</p>
  <pre><code>def distance(x1, x2) :
      return math.sqrt( ((x2[0]-x1[0])**2) + ((x2[1]-x1[1])**2) )
  
  
  def route(points):
      total = 0
      for element in range(1, len(points)):
          total += distance(points[element - 1], points[element])
      return total
  
  
  route([(4, 2), (6, 3), (5, 1)])
  </code></pre>
  <p>I'm unsure whether the <code>distance</code> function may also need to be altered to work through the list of tuples. But I essentially want to have the total distance between one point and the next as indexed in the list, as if something were travelling between the points.</p>