On Fri, 19 Sep 2003 19:35:54 -0400, "RR" <rr**@cornell.edu> wrote:
Is there an easy way in python to remove whitespace from a string?
From the ends or all of it?
From the ends,
" hello ".strip()
gives "hello"
There are lstrip and rstrip if you only want to strip from one end.
To get rid of all whitespace I'd probably do:
import string
string.join(" hello there world ".split(), "")
which gives
'hellothereworld'
Though there may be an easier way.