In Python, you can remove whitespace from the beginning and end of a string by using the strip()
method. Here's an example:
string = " Hello, World! "
string = string.strip()
print(string)
Output:
Hello, World!
As you can see, the strip()
method has removed the leading and trailing whitespace characters from the string.