rstrip()

Removes the specified set of characters from the right of the source string as long as a match is found.

Example

Python
str = 'You say tomato, I say tomato, the French say tomate.'
print(str.rstrip('apples.')) # the e and . are the match the last two characters in the source string.

Output

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