Python String strip() Method
Removes the specified set of characters from the start and end of the source string.
Syntax
Python
Copy Code
string.strip(characters = " ")
Parameters
Parameter | Description |
---|---|
characters |
Optional. A string representing the set of characters to remove from the start and end of the given string. The default is to strip space (" ") characters. |
Example
Python
Copy Code
str = 'You say tomato, I say tomato, the French say tomate.' print(str.strip('oYu '))
Output
say tomato, I say tomato, the French say tomate.