[Python] Remove Whitespace From a String

Posted on in Programming

>>> print "".join(" hello   world ".split())
helloworld

The key to the above is that split() separates the string on any amount of whitespace when no separator is specified.

python

My Bookshelf

Reading Now

Other Stuff