first letter of word capital letter
def capitalize_sentence(sentence):
# Split the sentence into a list of words words = sentence.split() # Capitalize the first letter of each word in the list capitalized_words = [word.capitalize() for word in words] # Join the capitalized words back into a sentence capitalized_sentence = ' '.join(capitalized_words) return capitalized_sentence # Test the function sentence = input("Enter a sentence: ") capitalized_sentence = capitalize_sentence(sentence) print("Capitalized sentence:", capitalized_sentence)
Comments
Post a Comment