Exercise: Clean names

Real data is messy. A sign-up form gives you " aDA lovelace " and you want "Ada Lovelace". Cleaning text like this is a common first step in take-home tasks and interview problems.

Exercise: finish clean_name. It should:

  • remove spaces at the start and end,
  • squash any run of spaces between words into one space,
  • start each word with a capital letter and make the rest lowercase.

A name that is empty or only spaces becomes "".

Hint: split() with no argument already does the first two steps. Then join the words back, and look at str.title.

Press Check to run the tests.