Created
November 19, 2019 06:30
-
-
Save devennorton/14acd42be61326d8d1c1a6698c73f64a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def title_case(title, minor_words): | |
final = "" | |
minor_words = [word.lower() for word in minor_words ] # make sure the minor words are all lower case | |
title = title.lower().split() # make title all lowercase and split into a list of words | |
final = title[0].capitalize() # always capitalize the first word | |
for word in title[1:]: #capitalize words not in list | |
if word not in minor_words: | |
final += ' ' + word.capitalize() | |
return final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment