title: Concatenate strings by groups python
body: <p>I would like to concatenate a list of strings into new strings grouped over values in a list. Here is an example of what I mean:</p>
  
  <p><strong>Input</strong></p>
  
  <pre><code>key = ['1','2','2','3']
  data = ['a','b','c','d']
  </code></pre>
  
  <p><strong>Result</strong></p>
  
  <pre><code>newkey = ['1','2','3']
  newdata = ['a','b c','d']
  </code></pre>
  
  <p>I understand how to join text. But I don't know how to iterate correctly over the values of the list to aggregate the strings that are common to the same key value.</p>
  
  <p>Any help or suggestions appreciated. Thanks.</p>