I am learning about .capitalize() and had a question.
I learned how to change lowercase letters to uppercase letters by dividing a string consisting of several sentences based on punctuation.
However, what should be done if ? and ! are mixed in the string?
Could you please tell me what is the appropriate way to change the input below to output?
wanted_input= "hello. my name is john. how are you? i'm fine. thank you."
wanted_output = "Hello. My name is john. How are you? I'm fine. Thank you."
#the wrong way i did it..wanted_input= "hello. my name is john. how are you? i'm fine. thank you." def capital_with(word_list, seperater): capital_split = word_list.split(seperater) capital_word = [] for i in capital_split: capital_word.append(i.capitalize()) capital_result = seperater.join(capital_word) return capital_result wanted_input= capital_with(wanted_input,'. ')wanted_input= capital_with(wanted_input,'? ')print(wanted_input) #Hello. my name is john. how are you? I'm fine. thank you.