Python remove extra spaces between words | Example code

Using re.sub() or split() + join() method you can remove extra spaces between words in Python. Python remove extra spaces between words Example Simple example code. Using re.sub() Regular expressions need to import the re module. It will replace any number of spaces with a single space: Output: Using split() and join() Without any arguments, Read More…