Question: Takes a non-empty string a_string and returns 2 values. The first returned value is a string where each character in a_string that is not an
Takes a non-empty string a_string and returns 2 values. The first returned value is a string where each character in a_string that is not an alphabet letter is replaced with a space. The second returned value is a dictionary with the frequency count of each character removed from a_string, where the key is the character, and the value, the number of times the character was removed from the string.
Hints:
The str.isalpha() method returns True if all characters in a string are alphabet letters (a-z).
When x = 'We', doing list(x) produces the list ['W', 'e']
Preconditions: While the function will receive non-empty strings, you should not make any assumptions about the characters in a_string
Test Data:
>>> removePunctuation("Dots...................... many dots..X")
('Dots many dots X', {'.': 24})
>>> data = removePunctuation("I like chocolate cake!!(!! It's the best flavor..;.$ for real")
>>> data[0]
'I like chocolate cake It s the best flavor for real'
>>> data[1]
{'!': 4, '(': 1, "'": 1, '.': 3, ';': 1, '$': 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
