title: Python join elements with same index
body: <p>I have a file with few thousand lines. I'd like to populate the dictionary line by line. The gene can work as a key. If the gene is found, it would append only the "rest" as values. I'd like to join the values for example with comma. This is where I'm now.</p>
  
  <pre><code>listfile = {}
  
  with open("Desktop/testfile", "r") as f:
      for lines in f:
          lines=lines.strip()
          gene=lines.split()[0]
          rest = lines.split()[1:]
  
  
          if gene not in listfile:
              listfile[gene] = rest
              #print gene, rest
          else:
              for items in rest:
  
                  listfile[gene].append(items)    
  
  
  for items in listfile.items():
      print items
  </code></pre>
  
  <p>input:</p>
  
  <pre><code>ACCA    39072094753 D   12
  ACCA    983954875454    G   11
  ACCA    098540980985    F   22
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>('ACCA', ['39072094753', 'D', '12', '983954875454', 'G', '11', '098540980985', 'F', '22'])
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>('ACCA', ['39072094753','983954875454','098540980985' 'D','G','F', '12','11','22'])
  </code></pre>