python trim leading and trailing whitespace code example
Example 1: remove trailing and leading spaces in python
text = " Hello World "
text.strip()
# Hello World
Example 2: python trim whitespace from end of string
>>> " xyz ".rstrip()
' xyz'