The strip() method removes characters from both left and right based on the argument. If the character argument is not passed as a parameter, then all the leading and trailing whitespaces are removed from the string.

Python String strip()

Python strip() is an inbuilt function that returns the copy of a string with both leading and trailing characters removed based on the string argument passed.

If you are looking for a solution to how to remove whitespace in Python or remove any specific character from string then Python string strip() is the answer.

Syntax

The syntax of the String.strip() method is the following.

string.strip([character])

#python #string.strip #python strip

Python String strip: How to Remove Whitespace In String
4.10 GEEK