title: Generating dictionary of lists in a loop (3.2.3)
body: <p>I need to create a dictionary where will be key a string and a value a list. The trick is I need to do it in a loop.</p>
  
  <p>My minimalised code looks like this at the moment:</p>
  
  <pre><code>for elem in xmlTree.iter():
  
    # skipping root element
    if elem.tag == xmlTree.getroot().tag:
      continue
    # this is supposed to be my temporary list
    tmpList = []
    for child in elem:
        tableWColumns[elem.tag] = tmpList.append(child.tag)
  print(tableWColumns)
  </code></pre>
  
  <p>This prints only the list created in the last iteration.</p>
  
  <p>Problem apparently lies in the fact that whenever I change the list, all of its references are changed as well. I Googled that. What I haven't Googled though is the way how can I deal with it when using a loop.</p>
  
  <p>The solution I am supposed to use when I want to keep the list is to copy it to some other list and then I can change the original one without losing data. What I don't know is how do I do it, when I basically need to do this dynamically.</p>
  
  <p>Also I am limited to use of standard libraries only.</p>