title: Python, Searching in a list of lists for the index of the nearest match from a given coordinate
body: <p>I have a list of lists with the following values:</p>
  <pre><code>field = [[0,  0,  0, -1,  0, 0, 0,  0,  0,  0],
       [0, -1,  0,  0,  0, 0, 0, -1,  0,  0],
       [0,  0,  0,  0, -1, 0, 0,  0, -1,  0],
       [0,  0, -1, -1, -1, 0, 0,  0,  0,  0],
       [0,  0,  0,  0,  0, 0, 0,  0, -1, -1]]
  </code></pre>
  <p>I need to find the the nearest value -1 from a given coordinate</p>
  <p>I managed to get the index for all matches</p>
  <p>My code so far:</p>
  <pre><code>x = 0
  y = 4
  value = -1
  coordinates = field[x][y]
  
  for i, row in enumerate(field):
      for j, elem in enumerate(row):
          if elem == value:
             print(i,j)
  </code></pre>
  <p>So for example if the coordinates given are (0,4) it should return the coordinates (1,7) witch matches the nearest value(-1)</p>
  <p>Thanks in advance</p>