To trim a string in Python you can use the following snippet.
Sample Python
input = " HelloWorld " input.strip() # returns "HelloWorld" input.lstrip() # returns "HelloWorld " input.rstrip() # returns " HelloWorld" input.replace(' ', '') # returns "HelloWorld"