how to remove spaces in python strings code example
Example 1: remove trailing and leading spaces in python
text = " Hello World "
text.strip()
# Hello World
Example 2: delete spaces in string python
>>> s.replace(" ", "")
text = " Hello World "
text.strip()
# Hello World
>>> s.replace(" ", "")