Question: Develop a Python function that accepts a string of text and removes all duplicate spaces (2 or more) and replaces them with a single
Develop a Python function that accepts a string of text and removes all duplicate spaces (2 or more) and replaces them with a single space. This regular expression also removes leading and trailing spaces. If a string containing all spaces is submitted, then your code would return an empty string. The function prototype MUST be: def cleanString(textStr): and returns a copy of the modified string.
Step by Step Solution
3.41 Rating (154 Votes )
There are 3 Steps involved in it
You can achieve this using Python and regular expressions Heres a P... View full answer
Get step-by-step solutions from verified subject matter experts
