Assume my string is
a = ' Hello, I am trying to strip spaces perfectly '
I know that:
- Stripping using
a.strip()
will remove preceding and leading spaces. - Using
a.replace(" ","")
I can remove one space etc
How to formulate this so that no matter how many spaces there are the output will always be rendered as only one space between each word and none at the start or end?
(in python and Unix) ... thanks!