Split in python and strip whitespace <p>I am learning Python, and currently working on reading in a file, splitting the lines and then printing specific elements. I am having trouble splitting multiple times though. The file I am working on has many lines that look like this</p> <pre><code>c0_g1_i1|m.1 gi|74665200|sp|Q9HGP0.1|PVG4_SCHPO 100.00 372 0 0 1 372 1 372 0.0 754 </code></pre> <p>I am trying to split it, first by tab and newline "/t/n", and then split the elements with |, I have tried .split and .strip and am not having much luck. I figured maybe if I just worked on a single line I could get the idea down, and then modify it into a loop that would access the file</p> <pre><code>blast_out = ("c0_g1_i1|m.1 gi|74665200|sp|Q9HGP0.1|PVG4_SCHPO 100.00 372 0 0 1 372 1 372 0.0 754") fields = blast_out.strip(' \t\r\n').split() subFields = fields.split("|") print(fields) print(subFields) </code></pre> <p>print(fields)</p> <pre><code>['c0_g1_i1|m.1', 'gi|74665200|sp|Q9HGP0.1|PVG4_SCHPO', '100.00', '372', '0', '0', '1', '372', '1', '372', '0.0', '754'] </code></pre> <p>print(subFields) generates an error </p> <pre><code>subFields = fields.split('|') AttributeError: 'list' object has no attribute 'split' </code></pre> <p>This is what I did just to try to strip the whitespace and the tabs, then to split on | but it doesn't seem to do anything. Eventually my desired output from this single string would be </p> <pre><code>c0_g1_i1 m.1 Q9HGP0.1 100.0 </code></pre>