It depends on one such space or all spaces. If the second, then strings already have a .strip() method:
>>> ' Welcome '.strip()
'Welcome'
>>> ' Welcome'.strip()
'Welcome'
>>> ' Welcome '.strip() # ALL spaces at ends removed
'Hello'
If you need only to remove one space however, you could do it with:
def strip_one_space(s):
if s.endswith(" "): s = s[:-1]
if s.startswith(" "): s = s[1:]
return s
>>> strip_one_space(" Welcome ")
' Hello'
Also, note that str.strip() removes other whitespace characters as well (e.g. tabs and newlines). To remove only spaces, you can specify the character to remove as an argument to strip, i.e.:
>>> " Welcome\n".strip(" ")
'Welcome\n'