Tidy up the customer names
A courier company in Karachi imports customer names from a web form. People type them in ALL CAPS, all lowercase, or with extra spaces and tabs. The mailing system needs one consistent style before labels are printed.
The cleaning rules are: remove spaces and tabs at the start and end, replace every run of spaces or tabs between words by one single space, and write every word with its first letter in upper case and all other letters in lower case. Words are separated by spaces only, so anne-marie becomes Anne-marie and o'brien becomes O'brien.
Task: the first line holds an integer N (1 to 50). The next N lines each hold one raw name with at least one visible character. Print the cleaned names, one per line, in the same order.
Sample tests
Input
3 muhammad ALI khan chen WEI AISHA bint ABDULLAH
Expected output
Muhammad Ali Khan Chen Wei Aisha Bint Abdullah
Input
2 anne-marie DUPONT o'brien seamus
Expected output
Anne-marie Dupont O'brien Seamus
Your answer is also checked against 2 hidden tests.
Need a hint?
str.split() with no argument already treats runs of spaces and tabs as one separator.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
