title: strange error message: 'dict_keys' object has no attribute 'pop'
body: <p>I have a strange problem with a code I'm trying to run on jupyter notebook(python version - 3.7.6)</p>
  <p>the code in this link (<a href="https://towardsdatascience.com/to-all-data-scientists-the-one-graph-algorithm-you-need-to-know-59178dbb1ec2" rel="nofollow noreferrer">https://towardsdatascience.com/to-all-data-scientists-the-one-graph-algorithm-you-need-to-know-59178dbb1ec2</a>) was kind of out of date because of the python version it was written on. I changed the &quot;.iteritems&quot; to &quot;.items&quot; and it worked well up to this part:</p>
  <pre><code>graph = Graph(g)
  graph.add_edge((&quot;Mumbai&quot;, &quot;Delhi&quot;),400)
  graph.add_edge((&quot;Delhi&quot;, &quot;Kolkata&quot;),500)
  graph.add_edge((&quot;Kolkata&quot;, &quot;Bangalore&quot;),600)
  graph.add_edge((&quot;TX&quot;, &quot;NY&quot;),1200)
  graph.add_edge((&quot;ALB&quot;, &quot;NY&quot;),800)
  
  g = graph.adj_mat()
  
  def bfs_connected_components(graph):
      connected_components = []
      nodes = graph.keys()
  
      while len(nodes)!=0:
          start_node = nodes.pop()
          queue = [start_node] #FIFO
          visited = [start_node]
          while len(queue)!=0:
              start = queue[0]
              queue.remove(start)
              neighbours = graph[start]
              for neighbour,_ in neighbours.items():
                  if neighbour not in visited:
                      queue.append(neighbour)
                      visited.append(neighbour)
                      nodes.remove(neighbour)
          connected_components.append(visited)
  
      return connected_components
  
  print bfs_connected_components(g)
  </code></pre>
  <p>It gives me this error <code>File &quot;&lt;ipython-input-48-660b0e10e666&gt;&quot;, line 32 print bfs_connected_components(g) ^ SyntaxError: invalid syntax</code></p>
  <p>So i tried to take off <code>print</code> and let just <code>bfs_connected_components(g)</code> to find what the debugger would return me.</p>
  <p>When I run the code without the <code>print</code> command it returns me the following error:</p>
  <pre><code>AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-49-09c142e436e3&gt; in &lt;module&gt;
       30     return connected_components
       31 
  ---&gt; 32 bfs_connected_components(g)
  
  &lt;ipython-input-49-09c142e436e3&gt; in bfs_connected_components(graph)
       14 
       15     while len(nodes)!=0:
  ---&gt; 16         start_node = nodes.pop()
       17         queue = [start_node] #FIFO
       18         visited = [start_node]
  
  AttributeError: 'dict_keys' object has no attribute 'pop'
  </code></pre>
  <p>which is weird, because there is <code>.pop</code> commands in the previous codes in this link and it worked well without any errors, except for the <code>.iteritems</code> expressions.</p>