How to Remove Any Whitespace From Beginning Or End in Python


In this example we will show how to remove any whitespace from the beginning or the end using the strip() method in Python.

Source Code

my_str = ' Python '

print(my_str)
print(my_str.strip())

Output:

 Python 
Python
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments