Question: Punctuations are typically individual characters such as !, ?, . etc. that are also often not useful in text analysis. Write function remove_punc(sentence, punctuation) which

Punctuations are typically individual characters such as "!", "?", "." etc. that are also often not useful in text analysis. Write function remove_punc(sentence, punctuation) which takes input parameters sentence (type string) and punctuation (type string), and returns a string that strips all trailing punctuations in sentence. Here, punctuations are NOT separated by a space, but they all should be removed. Also, you should not assume that punctuation would only contain the usual punctuations.

For example:

Test Result
simple_sentence = remove_punc("This is some, and \"I\" know it is a long one!", "?!.,") print(simple_sentence) This is some and "I" know it is a long one
simple_sentence = remove_punc("This is some, sente.nce an,d \"I\" know it is a long one!", ".,") print(simple_sentence) This is some sente.nce an,d "I" know it is a long one!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!