Python String rstrip() Method
Removes the specified set of characters from the end of the source string.
Syntax
Python
Copy Code
string.rstrip(characters)
Parameters
Parameter | Description |
---|---|
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
Copy Code
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