title: Python: Iterate over dict and list at the same time
body: <p>I want to write a function that can iterate over <code>dict</code> and <code>list</code> in the same way, like the following code. However, it does not work and blames that <code>iter</code> is not iterator.</p>
  
  <pre><code>def constructResult(*args):
      header = ''
      result = ''
      for arg in args :
          if isinstance(arg, dict) :
              iter = arg.items; #arg is a dict
          else:
              iter = arg #arg is a list 
          for (key,value) in iter :
              header = header + key + ","
  </code></pre>
  
  <p>Note: the inputs of this functions are either <code>dict</code> or <code>list</code>. This is an assumption. </p>
  
  <p>Here is the error msg:</p>
  
  <pre><code> File "./write-hole-collector.py", line 595, in constructResult
     for (key,value) in iter :
   TypeError: 'builtin_function_or_method' object is not iterable
  </code></pre>