title: How to find way to stop while loop when 1 first point meet last in polygon in python?
body: <p>I need to calculate the perimeter of a polygon by using only coordinates.</p>
  
  <p>My function:</p>
  
  <pre><code>def definePerimeter(xCoords, yCoords):
  
  i = 0
  sum = 0
  while xCoords[i] != xCoords[i+1] and yCoords[i] != yCoords[i+1]:
      dx = xCoords[i] - xCoords[i+1]
      dy = yCoords[i] - yCoords[i+1]
      dsquared = dx**2 + dy**2
      result = math.sqrt(dsquared)
      print "The list of segments:"
      print "The segment: ", result
      i += 1
      sum = sum + result           
  print  "Total 2D Perimeter is " , sum ,"m" *
  </code></pre>
  
  <p>gives wrong Perimeter (compared to ArcGIS).</p>
  
  <p>How to find way to stop while loop  when 1 first point meet last in polygon in python?</p>