I want to write a program that takes a sentence as input and then I want to capitalize the first letter of each word in the sentence. Here's what I have:
input_sentence = input("Enter a sentence: ")
words = input_sentence.split()
for word in words:
edited_word = word[0].upper() + word[1:]
print("Edited sentence:", ' '.join(words))
When I run this code, it doesn't seem to change the sentence at all. But I do have upper()
. What's the problem?
I tried to enter a sentence, but the sentence didn't been capitalized:
Enter a sentence: i am writing a sentence
Edited sentence: i am writing a sentence
The required output is like:
Enter a sentence: i am writing a sentence
Edited sentence: I Am Writing A Sentence