#256 · Strings · Beginner · 40 XP · about 8 min
Book and film titles are written in title case, but short words like "of" and "the" usually stay lowercase. Write title_case(title) that formats a title with these rules:
a, an, the, of, and, in and on stay completely lowercase,The words in title are separated by single spaces and can be in any mix of upper and lower case.
title_case("the lord of the rings") # returns 'The Lord of the Rings' title_case("a tale OF two cities") # returns 'A Tale of Two Cities' title_case("the world we live in") # returns 'The World We Live In'
In the last example "in" is the last word, so it gets a capital.
title has at least one word, and the words contain only letters.
First solves only, ranked by stars and then time.