Punctuations are typically individual characters such as "1", "?", "." etc. that are also often not useful in text analysis. Write a 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!", "?!.,") This is some and "I" know it is a long one print (simple sentence) simple sentence = remove_punc("This is some, sente.nce an,d "1\" know it is a long one!", ".,") This is some sente.nce an,d "I" know it is a long one! print(simple_sentence)
Punctuations are typically individual characters such as "1", "?", "." etc. that are also often not useful in text analysis. Write a 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!", "?!.,") This is some and "I" know it is a long one print (simple sentence) simple sentence = remove_punc("This is some, sente.nce an,d "1\" know it is a long one!", ".,") This is some sente.nce an,d "I" know it is a long one! print(simple_sentence)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images