fork download
  1. f = ['Mike -3,434.09 testing testing 123', 'Mike -3,434.09 testing 256', 'No operation here']
  2. lines = []
  3. for line in f:
  4. split = line.split('\t')
  5. if len(split) > 3:
  6. tmp = split[:2] # Slice the first two items
  7. tmp.append("_tab_".join(split[2:])) # Append the rest joined with _tab_
  8. lines.append("\t".join(tmp)) # Use the updated line
  9. else:
  10. lines.append(line) # Else, put the line as is
  11.  
  12. for line in lines:
  13. print(line)
Success #stdin #stdout 0.03s 9276KB
stdin
Standard input is empty
stdout
Mike	-3,434.09	testing_tab_testing_tab_123
Mike	-3,434.09	testing_tab_256
No	operation	here