title: Python: Iterate through a list that refers to other lists
body: <p>This isn't a list of lists, didn't know the proper way to ask this.</p>
  
  <p>I have a list of variables and each one is a list, I am trying to get the variable from the list.</p>
  
  <pre><code>&gt;&gt;&gt; print sortedList
  ['group0', 'group1', 'group2', 'group3', 'group4', 'group5', 'group6', 'group7', 'group8', 'group9', 'group10', 'group11', 'group12']
  &gt;&gt;&gt; print group0
  ['abc']
  &gt;&gt;&gt; print group2
  ['combine', 'id']
  </code></pre>
  
  <p>my loop fails to do what I want</p>
  
  <pre><code>for group in sortedList:
      for job in group:
          print job
  g
  r
  o
  u
  p
  0
  ....
  </code></pre>
  
  <p>The number of group lists varies so I don't know a good way to iterate through them except for getting a list of them</p>
  
  <p>This is how I get sortedList:</p>
  
  <pre><code>group_re = re.compile('(group)(\d+)', re.I)
  totalVars = vars().keys()
  myList = [ s for s in totalVars if group_re.match(s)]
  sortedList = sorted(myList, key=lambda x: (len (x), x))
  </code></pre>