title: Distance formula between two points in a list
body: <p>I need to take a list I have created and find the closest two points and print them out. How can I go about comparing each point in the list?</p>
  
  <p>There isn't any need to plot or anything, just compare the points and find the closest two in the list.</p>
  
  <pre><code>import math # 'math' needed for 'sqrt'
  
  # Distance function
  def distance(xi,xii,yi,yii):
      sq1 = (xi-xii)*(xi-xii)
      sq2 = (yi-yii)*(yi-yii)
      return math.sqrt(sq1 + sq2)
  
  # Run through input and reorder in [(x, y), (x,y) ...] format
  oInput = ["9.5 7.5", "10.2 19.1", "9.7 10.2"] # Original input list (entered by spacing the two points).
  mInput = [] # Manipulated list
  fList = [] # Final list
  for o in oInput:
      mInput = o.split()
      x,y = float(mInput[0]), float(mInput[1])
      fList += [(x, y)] # outputs [(9.5, 7.5), (10.2, 19.1), (9.7, 10.2)]
  </code></pre>