Deviopath › Python

Capitalize Each Word

Easy · Strings

word.capitalize() makes the first letter uppercase and the rest lowercase. " ".join(words) glues a list of strings back together with spaces.

Write a function capitalize_words(text) that capitalizes every word of a sentence, so "pYTHON is FUN" becomes "Python Is Fun". Words are separated by single spaces.

Next: Normalize Spaces