title: Combine two dictionaries, concatenate string values?
body: <p>Related: <a href="https://stackoverflow.com/questions/11011756/is-there-any-pythonic-way-to-combine-two-dicts-adding-values-for-keys-that-appe?lq=1">Is there any pythonic way to combine two dicts (adding values for keys that appear in both)?</a></p>
  
  <p>I'd like to merge two string:string dictionaries, and concatenate the values. The above post recommends using <code>collections.Counter</code>, but it doesn't handle string concatenation.</p>
  
  <pre><code>&gt;&gt;&gt; from collections import Counter
  &gt;&gt;&gt; a = Counter({'foo':'bar', 'baz':'bazbaz'})
  &gt;&gt;&gt; b = Counter({'foo':'baz'})
  &gt;&gt;&gt; a + b
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/collections.py", line 569, in __add__
  TypeError: cannot concatenate 'str' and 'int' objects
  </code></pre>
  
  <p>(My guess is Counter tries to set <code>b['baz']</code> to 0.)</p>
  
  <p>I'd like to get a result of <code>{'foo':'barbaz', 'baz':'bazbaz'}</code>. Concatenation order doesn't matter to me. What is a clean, Pythonic way to do this?</p>