Python String strip() Method

Removes the specified set of characters from the start and end of the source string.

Syntax

Python
string.strip(characters = " ")

Parameters

ParameterDescription
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
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.