Suppose this string:
The fox jumped over the log.
Turning into:
foo is your string:
foo
" ".join(foo.split())
Be warned though this removes "all whitespace characters (space, tab, newline, return, formfeed)" (thanks to hhsaffar, see comments). I.e., "this is \t a test\n" will effectively end up as "this is a test".
"this is \t a test\n"
"this is a test"