title: Cycling through Keys in a Dictionary
body: <p>So I need to define some function in python that will print each dictionary key with each value separately. Everything is an Airport Code, so the output, for example, should look like "There is a direct flight from ORD to JFK." And I need to print that for every direct flight from every airport. </p>
  
  <p>The following is an example input</p>
  
  <pre><code>{"ORD" : ["JFK", "LAX", "SFO"],
  "CID" : ["DEN", "ORD"],
  "DEN" : ["CID", "SFO"],
  "JFK" : ["LAX"],
  "LAX" : ["ORD"],
  "SFO" : []}
  </code></pre>
  
  <p>My function is</p>
  
  <pre><code>def printAllDirectFlights(flightGraph):
      x = len(flightGraph)
      y = 0
      while y &lt; x:
          n = len(flightGraph[y])
          z = 0
          while z &lt; n:
              print("There is a direct flight from",flightGraph[y],"to",flightGraph[y][z],".")
  </code></pre>
  
  <p>I thought this would work, but obviously I'm wrong. How do I cycle through the keys? I know that if I were, for example to write</p>
  
  <pre><code>print(flightGraph["ORD"][0])
  </code></pre>
  
  <p>then I would receive JFK as an output, but how do I go about cycling through the keys of a dictionary?</p>