title: Python: Grouping Multiple Lists Based On Same Element
body: <p>So I have a tab separated text file like given below:</p>
  
  <pre><code>23      Hello How are you?
  23      What's up?
  24      I am using Python
  </code></pre>
  
  <p>I want to separate and group the above data so that it looks like this:</p>
  
  <pre><code>23      Hello How are you? What's up?
  24      I am using Python
  </code></pre>
  
  <p>Basically I want to group the text with the same value of the first column (and then write them into separate text files of 23.txt and 24.txt)</p>
  
  <p>I have the code as written below:</p>
  
  <pre><code>def data_extraction(inputfile):
  
  ifile = open(inputfile, "r")
  lines = ifile.readlines()
  
  
  for value in lines:
      each_line = value.split('\t')
      service_order = each_line[0]
      text = each_line[-1]
  </code></pre>
  
  <p>The above will give me multiple lists (<code>value = ['23', 'Hello How are you?']</code>  and so on) inside the for loop. What do I need to do group the same column and their corresponding texts?</p>