python replace all whitespace with single space code example
Example 1: replace multiple spaces with single space python
' '.join(mystring.split())
Example 2: python 3 replace all whitespace characters
>>> s = " \t foo \n bar "
>>> "".join(s.split())
'foobar'
Example 3: reolace double space ti single space in python'
' '.join(mystring.split())