Title case is a style of writing that is used for the titles of articles, books, movies, and other works. The rules for writing in title case are:
1) Always capitalize the first word.
2) Capitalize all words except the following parts of speech:
- articles – a, an, the
- coordinating conjunctions – and, but, for, nor, or, so, yet
- short prepositions – to, in, up, from etc
Input : The quick brown fox jumps over the lazy dog. Output : The Quick Brown Fox Jumps over the Lazy Dog. Input : A tale of two cities Output : A Tale of Two Cities
- Make a list of all the words that have to be in lower case.
- For every word in the input, check whether it is in the above list or not.
- If yes then ignore the word, if no then capitalize its first character.
The implementation of the above algorithm is:
The Quick Brown Fox Jumps over the Lazy Dog. A Tale of Two Cities
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.