I have a string sentence
that contains trailing punctuation that I want to remove. To do this I'm passing a string parameter punctuation
to my function remove_punc
that contains the trailing punctuation that I want to remove:
def remove_punc(sentence, punctuation):
"""takes input parameters sentence (type string) and
punctuation (type string), and returns a string that
strips all trailing punctuations in sentence."""
I have tried sentence.rstrip(punctuation)
for the example:
remove_punc("This is some, and \"I\" know it is a long one!", "?!.,")
However this returns:
'This is some, and "I" know it is a long one'
The expected output is:
'This is some and "I" know it is a long one'
Am I using rstrip()
incorrectly?