Python String rstrip() Method

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

Syntax

Python
string.rstrip(characters)

Parameters

ParameterDescription
characters Optional. A string representing the set of characters to remove from the 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.rstrip('aeiou'))    # let's remove all vowels from the end.

Output

You say tomato, I say tomato, the French say tomat