title: Python rstrip and split
body: <p>Hi I want to remove strip newline from my list and get the third word for each element. I am using split and rstrip. This is my code:</p>
  
  <pre><code># obtain just compound ids from list
  just_compound_id = []
  for line in final_list:
      split_file = line.split(' ')
      split_file = line.rstrip()
      just_compound_id.append(split_file[2])
      print(just_compound_id)
  </code></pre>
  
  <p>but I get a really weird output, something like this </p>
  
  <pre><code>['I']
  ['I', 'I']
  ['I', 'I', 'I']
  ['I', 'I', 'I', 'I']
  ['I', 'I', 'I', 'I', 'I']
  </code></pre>
  
  <p>**EDIT</p>
  
  <p>this is my input </p>
  
  <pre><code>['UNIQUE-ID - ASN\n', 'UNIQUE-ID - D-GLT\n', 'UNIQUE-ID - 4-AMINO-
  BUTYRATE\n', 'UNIQUE-ID - CPD-8569\n', 'UNIQUE-ID - CPD-17095\n', 'UNIQUE-ID 
  - CPD-17880\n', 'UNIQUE-ID - GLY\n', 'UNIQUE-ID - CPD-18298\n', 'UNIQUE-ID - 
  D-SERINE\n', 'UNIQUE-ID - ACETYLCHOLINE\n', 'UNIQUE-ID - DOPAMINE\n', 
  'UNIQUE-ID - SEROTONIN\n', 'UNIQUE-ID - HISTAMINE\n', 'UNIQUE-ID - 
  PHENYLETHYLAMINE\n', 'UNIQUE-ID - TYRAMINE\n', 'UNIQUE-ID - CPD-58\n', 
  'UNIQUE-ID - 1-4-HYDROXYPHENYL-2-METHYLAMINOETHAN\n', 'UNIQUE-ID - 
  TRYPTAMINE\n']
  </code></pre>