# Remove whitespace from the beginning or at the end of a string
my_string = " Hello, World! "
print("Original string:", my_string)
trimmed_string = my_string.strip()
print("Trimmed string:", trimmed_string)
Original string: Hello, World!
Trimmed string: Hello, World!
Hello, World!
"` to the variable `my_string
`. We then use the `print()
` function to print the original value of `my_string
`.strip()
` method to remove any whitespace characters from the beginning or at the end of `my_string
`. We assign the result of this operation to the variable `trimmed_string`.print()
` function to print the trimmed string.