eliminating multiple occurrences of whitespace in python

Posted by tipu on Stack Overflow See other posts from Stack Overflow or by tipu
Published on 2010-06-01T15:29:32Z Indexed on 2010/06/01 15:33 UTC
Read the original article Hit count: 157

Filed under:
|

If I have a string

"this is   a    string"

How can I shorten it so that I only have one space between the words rather than multiple? (The number of white spaces is random)

"this is a string"

© Stack Overflow or respective owner

Related posts about python

Related posts about string-manipulation