The rstrip Method in Python: Removing Characters from the Right

Returns a copy of the specified string with specified characters removed from the end (right r — right).

rstrip([chars])

  • chars=None -- a string of characters to remove. If not specified, whitespace characters are removed. This is not a prefix or suffix, but a list of characters to remove.
'abca'.rstrip('ac')  # 'ab'

The method behaves like lstrip, but it removes characters on the right.