1.Create a function that will let you enter in a word or
sentence in lower case (as a user input) and will convert the input
to a string with the first letter capitalized. Next, use the format
method to print the following result:
"Before: word, After: Word"
i.e. >>> Enter a word: house
>> Before: house, After: House
2. Write a program that will let you enter a sentence and will
print each word
out separately with the first letter capitalized. Hint: use the
string's
**split** function together with what you know about **for loops**
and
**lists**.
def capitalize(): word = input("Enter a word: ") res = word[0].upper() + word[1:] print("Before: {}, After: {}".format(word,res)) capitalize()
######################################
# Code s = input("Enter sentence: ") for x in s.split(): print(x[0].upper() + x[1:])
Get Answers For Free
Most questions answered within 1 hours.