The title() is built-in function which convert the string to title case, it means that every first word is capitalised and all subsequent letters in lowercase.
txt="Hello buddy how you doing?" print(txt.title())
Output: Hello Buddy How You Doing?
Now write it manually, make its logic:
def title(text): output=[] for word in text.split(' '): output.append(word[0].upper()+word[1:].lower()) return ' '.join(output) print(title('Hi how you doing?'))
Hi How You Doing?
Top comments (0)