PY-6
Normalize Whitespace under a Rule
Task
Write normalize_whitespace(text). Normalize spaces and tabs inside each line
without removing or adding any \n line boundaries.
For each line:
- remove spaces and tabs from the beginning and end;
- replace each run of spaces or tabs between non-whitespace characters with one space.
Empty lines must remain in the same order. If text ends with \n, the result
must also end with \n.
The input uses only spaces, tabs, and \n as whitespace. It does not contain
\r carriage returns.
Example
The words are separated consistently, while both line boundaries remain.
The final line boundary remains present.
Your implementation
Edit solution.py and keep this function name and signature:
Return the normalized text as a string. Do not print it or ask for input. An empty input must return an empty string.