title: Navigating through a dictionary in Python
body: <p>I have a dictionary called "locations". A function I'm writing for the dictionary is set up in the format (d, description, current) where 'd' references the dictionary, 'description' references a string describing the location we are looking for, and 'current' references the spot we currently are in the dictionary as a pair of coordinates (x,y). </p>
  
  <p>Basically, each location has multiple positions in the dictionary each with its own pair of coordinates and my goal is to find the closest position to where we currently are in the dictionary (current). The strategy is to use the distance formula to calculate this. </p>
  
  <p>For example if we were looking for the nearest gas station and we were currently at (2,2), the function should return (3,1) for the nearest station if the two stations were at (3,1) and (1,4) as (3,1) is closer to (2,2)  Any advice on my current code would be appreciated. </p>
  
  <p>Code:</p>
  
  <pre><code>def closest(d, description, current):
      current_location = (x, y)
      d = {(3,1):'gas', (1,4):'gas', (2,1):'food', (5,5):'food'}
      distancesFromCurrent = [distanceFormula(z, current_location) for z in places]
      for z in d:
      if z &lt; minimum float:
          return z
  </code></pre>
  
  <p>My current code has no errors but is definitely not working correctly. It is just returning 0,0 and I'm not sure how I can fix it to return the coordinates of the closest location to our current position.</p>