How to remove empty separators from read files in Python?
<p>Here is my input file sample (z.txt)</p>

<pre><code>&gt;qrst
ABCDE--  6  6 35 25 10
&gt;qqqq
ABBDE--  7  7 28 29  2
</code></pre>

<p>I store the alpha and numeric in separate lists. Here is the output of numerics list
     #Output : ['', '6', '', '6', '35', '25', '10']
               ['', '7', '', '7', '28', '29', '', '2']</p>

<p>The output has an extra space when there are single digits because of the way the file has been created. Is there anyway to get rid of the '' (empty spaces)?</p>

<p>A quick fix would be a conditional within a list comprehension:</p>

<pre><code>In [4]: a = ['', '7', '', '7', '28', '29', '', '2']

In [5]: [i for i in a if i]
Out[5]: ['7', '7', '28', '29', '2']
</code></pre>

<p>List comprehensions are generally considered more pythonic than filter and map.</p>

python input split emptydatatext