title: Python: How can I modify dictionary values in a for loop alternating the keys?
body: <p>I am new to Python (and to programming).</p>
  
  <p>I'd like to modify a dictionary in a for loop by alternating the key of the dictionary. I wrote the following code, which was unsccessful, however:</p>
  
  <pre><code>#coding: utf-8
  dict1 = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
  dict2 = dict.fromkeys(dict1.values(),[])
  
  for key in dict2:
      if key == 'value1':
          dict2[key].extend(['test1', 'test2'])
      elif key == 'value2':
          dict2[key].extend(['test3', 'test4'])
      elif key == 'value3':
          dict2[key].extend(['test5', 'test6'])
  
  print (dict2['value1'])
  print (dict2['value3'])
  </code></pre>
  
  <p>I expected the results to be:</p>
  
  <pre><code> ['test5', 'test6']
   ['test1', 'test2']
  </code></pre>
  
  <p>but I actually got:</p>
  
  <pre><code> ['test5', 'test6', 'test3', 'test4', 'test1', 'test2']
   ['test5', 'test6', 'test3', 'test4', 'test1', 'test2']
  </code></pre>
  
  <p>I guess the problem might come from my making the dictionary from another dictionary using "dict.fromkeys", but I couldn't see why it is problematic even if it is the case.</p>
  
  <p>Thanks for your attention. Looking forward to your suggestions.</p>