title: Group repeating list objects with itertools.groupby()
body: <p>I have a list, where I want to group the repeating objects into a single object in the new list. Basically, convert this: </p>
  
  <pre><code>s = ['0.352125', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0.241041', '0.313429', '1', '1']
  </code></pre>
  
  <p>to this: 
  <code>s_new = ['0.352125', '4*1','8*0', '0.241041', '0.313429','2*1']</code></p>
  
  <p>I have tried <code>itertools.groupby()</code> function (python 2.7) as below:</p>
  
  <pre><code>from itertools import groupby
  s_g = [list(g) for k, g in groupby(s)]
  s_new = [', '.join('{}*{}'.format(sum(1 for _ in g), k) for k, g in groupby(s_g))]
  </code></pre>
  
  <p>As a result, I get: </p>
  
  <p><code>s_new = ["1*['0.352125'], 1*['1', '1', '1', '1'], 1*['0', '0', '0', '0', '0', '0', '0', '0'], 1*['0.241041'], 1*['0.313429'], 1*['1', '1']"]</code></p>
  
  <p>Apparently, this is not the list format I'm trying to get. Could someone please help me with this? </p>