How to delete python spaces code example
Example 1: delete spaces in string python
>>> s.replace(" ", "")
Example 2: how to remove spaces in string in python
sentence = ' hello apple '
sentence.strip()
>>> 'hello apple'
Example 3: remove tab space from string in python
import re
mystr = "I want to Remove all white \t spaces, new lines \n and tabs \t"
print re.sub(r"\W", "", mystr)
Output : IwanttoRemoveallwhitespacesnewlinesandtabs