Suppose this string:
The fox jumped over the log.
Turning into:
A simple soultion
>>> import re >>> s="The fox jumped over the log." >>> print re.sub('\s+',' ', s) The fox jumped over the log.