Back
Suppose this is the string:
The fox jumped over the log.
It would result in:
What is the simplest, 1-2 liner that can do this? Without splitting and going into lists...
Try as shown below:
>>> import re>>> re.sub(' +', ' ', 'The quick brown fox')'The quick brown fox'
>>> import re
>>> re.sub(' +', ' ', 'The quick brown fox')
'The quick brown fox'
31k questions
32.8k answers
501 comments
693 users