sentence = ' hello apple' sentence.strip() >>> 'hello apple'
>>> import re >>> re.sub(' +', ' ', 'The quick brown fox') 'The quick brown fox'