Question: python problem 1) Removing punctuation Write a function remove_punc (text, punc) that takes two string arguments: a string of text that may contain some unwanted
python problem
1) Removing punctuation Write a function remove_punc (text, punc) that takes two string arguments: a string of text that may contain some unwanted punctuation, and a string pune that contains one copy of each punctuation character to be removed. remove_pune will return a string that is identical to text, except with any character that appears in punc removed. Hint: Use the .replace string method inside a for loop, to replace each character in punc with an empty string, whenever it appears in text. Examples: >>> remove_punc('Remlove, o?nly th3 exclamati.n points!', '!') 'Remove, only th3 excamati.n points' >>> remove_punc('??Gelt r;!; id of m, o,s,t punctuation', '.!;,?') 'Get rid of most punctuation' Would this function work to remove characters that are not punctuation?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
