title: How to access an element from a list of lists in python networkX? TypeError: 'int' object is not iterable
body: <p>I have an output from my  loop, where G is a Graph from networkX.</p>
  <pre><code>for node in G.nodes():
      start_end = [(node,k) for k,v in nx.shortest_path_length(G, node).items() if v == d]
      print (start_end)
  </code></pre>
  <p>which is lots of list classes with tuples inside  them.
  (if it was just one list, it would be easy to do start_end[0][0].)</p>
  <pre><code>&lt;class 'list'&gt;
  &lt;class 'list'&gt;
  &lt;class 'list'&gt;
  &lt;class 'list'&gt;
  ....
  []
  []
  []
  []
  []
  []
  [('45', '27'), ('45', '26'), ('45', '39'), ('45', '24'), ('45', '81'), ('45', '29'), ('45', '46'), ('45', '51'), ('45', '23'), ('45', '8'), ('45', '60'), ('45', '83'), ('45', '86'), ('45', '149'), ('45', '18'),  ('45', '99'), ('45', '78'), ('45', '120'), ('45', '134'), ('45', '121'), ('45', '122')]
  []
  []
  []
  []
  []
  []
  [('129', '134')]
  []
  [('134', '92'), ('134', '97')]
  []
  []
  []
  []
  []
  </code></pre>
  <p>I want to grab the first element of the longest list  '45' , in this example.
  I have tried to sort the lists by length.</p>
  <pre><code>sorted(start_end, reverse=True)
  max(start_end)
  
  </code></pre>
  <p>which yields an error</p>
  <pre><code>#TypeError: 'int' object is not iterable
  </code></pre>
  <p>I have also tried</p>
  <pre><code>start_end = len([(node,k) for k,v in nx.shortest_path_length(G_sc, node).items() if v == d])
  print(max(current))
  
  </code></pre>
  <p>with the same error.</p>
  <p>Below is the  pseudo-code that you can reproduce.
  here, how can I access the tuple ((2, 1) from the second (longest) list?</p>
  <pre><code>In: 
  import networkx as nx
  G = nx.DiGraph()
  
  G.add_edge(1,2); G.add_edge(1,4)
  G.add_edge(3,1); G.add_edge(3,4)
  G.add_edge(2,3); G.add_edge(4,3)
  
  for node in G.nodes():
      start_end_nodes = [(node, k) for k,v in nx.shortest_path_length(G, 
                        node).items() if v == 2]
      
      print(start_end_nodes)
  
  Out:
  [(1, 3)]
  [(2, 1), (2, 4)]
  [(4, 1)]
  [(3, 2)]
  </code></pre>