Normalize whitespace
Your task
Text pasted into a form arrives with messy whitespace. Normalize it: replace every run of spaces, tabs, and newlines with a single space, and remove leading and trailing whitespace entirely. All other characters are unchanged. For example, ' hello\t\tworld \n twice ' becomes 'hello world twice'.
Examples
normalize_spaces(text: str) -> strExample 1
Input
normalize_spaces(" hello\t\tworld \n twice ")Output
"hello world twice"