how to remove unwanted space in python string code example
Example 1: python delete white spaces
sentence = ' hello apple'
sentence.strip()
>>> 'hello apple'
Example 2: remove extra spaces python
>>> import re
>>> re.sub(' +', ' ', 'The quick brown fox')
'The quick brown fox'