How to remove whitespace in a list
<p>I can't remove my whitespace in my list. </p>

<pre><code>invoer = "5-9-7-1-7-8-3-2-4-8-7-9"
cijferlijst = []

for cijfer in invoer:
    cijferlijst.append(cijfer.strip('-'))
</code></pre>

<p>I tried the following but it doesn't work. I already made a list from my string and seperated everything but the <code>"-"</code> is now a <code>""</code>.  </p>

<pre><code>filter(lambda x: x.strip(), cijferlijst)
filter(str.strip, cijferlijst)
filter(None, cijferlijst)
abc = [x.replace(' ', '') for x in cijferlijst]
</code></pre>

<p>This looks a lot like the following question:
<a href="http://stackoverflow.com/questions/3232953/python-removing-spaces-from-list-objects">Python: Removing spaces from list objects</a></p>

<p>The answer being to use <code>strip</code> instead of <code>replace</code>. Have you tried </p>

<pre><code>abc = x.strip(' ') for x in x
</code></pre>

python list