For example, I have this sentence:
hello. my name is Jess. what is your name?
and I want to change it into:
Hello. My name is Jess. What is your name?
I came up with this code, but I have one problem with connecting everything back together
def main():
name = input('Enter your sentence: ')
name = name.split('. ')
for item in name:
print (item[0].upper() + item[1:], end='. ')
When I put in the sentence, it will return:
Hello. My name is Jess. What is your name?.
How can I stop the punctuation from appearing at the end of the sentence? Also, what if I have a question in the middle, for example:
hi. what is your name? my name is Jess.
This one is better solution
x = "hello. my name is Jess. what is your name?"
print( '. '.join(map(lambda s: s.strip().capitalize(), x.split('.'))))
output:
Hello. My name is jess. What is your name?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With