Remove Whitespace From String in Python Using strip() Function

(Last Updated On: 24/03/2023)

Python Program to Remove Whitespace From String Using strip() Function

# Remove Whitespace From String in Python Using strip() Function

my_string = " Python "

# strip() removes the leading and trailing characters including the whitespaces from a string.
print(my_string.strip())

Output:

Python

Leave a Reply

Your email address will not be published. Required fields are marked *