Suppose this string:
The fox jumped over the log.
Turning into:
Another alternative:
>>> import re >>> str = 'this is a string with multiple spaces and tabs' >>> str = re.sub('[ \t]+' , ' ', str) >>> print str this is a string with multiple spaces and tabs