Skip to contentKEEP THE CRAFTTHE SANCTUARY

Normalize Text

Lowercase a string and squeeze all of its whitespace down to single spaces.

The problem

Implement normalize_text(text). Return the words of text in lowercase, separated by exactly one space, with no whitespace at the start or the end. Any whitespace counts as a separator: spaces, tabs and newlines. For example, " Hello PYTHON " becomes "hello python", and "A\tB\nC" becomes "a b c".

Starter code

def normalize_text(text):
    pass

Public examples

  1. text = " Hello PYTHON "gives"hello python"

Solving it in the practice book needs an active paid plan.

Open it in the practice book
One thought at a time.