If your using Python and you’ve got a string that you want to remove leading or trailing spaces from then Python makes this very simple. This is how:
myString.lstrip() # This removes leading spaces
myString.rstrip() # This removes trailing spaces
myString.strip() # This removes both leading and trailing spaces.
Additionally you can specify a parameter to the strip commands so if you wanted to strip a comma you can write this:
myString.rstrip(',') # This removes trailing commas