split long string inside one list to small lists
<p>How do you split this long string of one list to small multi-lists as show on the output  ? (I have file has 100 lines)</p>

<pre><code>Num=['S', 'I', 'R', 'T', 'S', 'A', 'V', 'P', 'S', 'P', 'C', 'G', 'K', 'Y', 'Y', 'T', 'L', 'N', 'G', 'S', 'K', '\n', ',', 'S', 'T', 'P', 'C', 'T', 'T', 'I', 'N', 'K', 'V', 'K', 'A', 'S', 'G', 'M', 'K', 'A', 'I', 'M', 'M', 'A', '\n']
</code></pre>

<p>Output should look like this:</p>

<pre><code>['S', 'I', 'R', 'T', 'S', 'A', 'V', 'P', 'S', 'P', 'K', 'G', 'K', 'Y', 'Y', 'T', 'L', 'N', 'G', 'S', 'K']

['S', 'T', 'P', 'C', 'T', 'T', 'I', 'N', 'K', 'V', 'K', 'A', 'S', 'G', 'M', 'K', 'A', 'I', 'M', 'M', 'A']
</code></pre>

<p>First <code>join</code> the elements, <code>strip()</code> leading-trailing whitespace characters, <code>split</code> on a new line <code>\n</code> and comma <code>,</code> and then map them to a list again.</p>

<p>In short:</p>

<pre><code>l1, l2 = map(list, "".join(Num).strip().split('\n,'))
</code></pre>

<p>Now, <code>l1, l2</code> look, respectively:</p>

<pre><code>['S', 'I', 'R', 'T', 'S', 'A', 'V', 'P', 'S', 'P', 'C', 'G', 'K', 'Y', 'Y', 'T', 'L', 'N', 'G', 'S', 'K']
</code></pre>

<p>and</p>

<pre><code>['S', 'T', 'P', 'C', 'T', 'T', 'I', 'N', 'K', 'V', 'K', 'A', 'S', 'G', 'M', 'K', 'A', 'I', 'M', 'M', 'A']
</code></pre>

python string python-2.7 python-3.x