title: Finding minimum distance between points using two iterative lists and 'in range (0,len a_list))
body: <p>So i have a question that needs solving and the answer has to be fixed within a set of parameters. I've searched Stack for hours on this but can't find anything that helps. I'm new to Python and this is part of a quiz but without enough knowledge on iteration through lists I'm lost!</p>
  <p>I know the solution to this having done the brute force method manually and looking at the scatter graph that comes out but I can't get the code to generate what I expect.</p>
  <p><strong>Code as follows</strong></p>
  <pre><code>import matplotlib.pyplot as plt
  
  xs = [1, 7, 2, 10, 3, 4, 8, 4] 
  ys = [1, 2, 4, 9, 16, 0, 12, 8]
  
  plt.scatter(xs, ys)
  
  import math
  
  &quot;&quot;&quot;Compute the minimun distance between points given as lists for 
  x, y coordinates. Return the values for the closest pair of points.&quot;&quot;&quot; 
  
  def min_distance(xs, ys):
      &quot;&quot;&quot;assume inputs xs, ys are lists of same length representing
      x,y point ordinates where points are distinct
      start with a high number as lowest&quot;&quot;&quot;
      min_dist = 99999
      min_index1 = 0
      min_index2 = 0
      
      # iterate x,y ordinates to find minimum distance
      &quot;&quot;&quot;YOUR CODE GOES HERE - BEGIN&quot;&quot;&quot;
      for i in range (0, len(xs)):
          for j in range (0, len(ys)):
              if i &gt; min_index1 and j &gt; min_index2:
                  min_dist = math.sqrt((xs[i] - xs[j])**2 + (ys[i] - ys[j])**2)
      &quot;&quot;&quot;YOUR CODE GOES HERE - END&quot;&quot;&quot;
  
      return(min_index1, min_index2, min_dist)
  
  index1, index2, d = min_distance(xs, ys)
  print(&quot;Closest ordinates {},{} with distance: {}&quot;.format(index1,index2,d))
  </code></pre>
  <p><em><strong>The only code I'm supposed to change is the bit in the grey box that I have attempted to code myself (after it states ENTER YOUR CODE HERE)</strong></em></p>