When working with
rstrip, you might think that this would be the case:
While this seems intuitive, it would actually result in:
>>> "Monty Python".rstrip(" Python") "Monty"
as Python interprets the argument to these functions as a set of characters rather than a substring.
If you want to remove a prefix/suffix from a string,
str.removesuffix are recommended and were added in 3.9.
See the documentation of str.removeprefix and str.removesuffix for more information.
>>> "Monty Python".removesuffix(" Python") "Monty"