Reputation: 29
So far I'm able to capitalize the first word of the sentence, but I need every first letter after a period to be capitalized. This is what I have:
def main():
input1 = input('Enter your input here: ')
capitalize = str.capitalize(input1)
print("The capitalized version:", capitalize)
main()
Upvotes: 3
Views: 1525
Reputation: 2174
Just use .title() method of a string (either ASCII or Unicode is fine).
For your instance:
>>> 'Enter your input here: '.title()
'Enter Your Input Here: '
Upvotes: -2
Reputation: 490283
Use Sentence Case of the rename package.
>>> from tl.rename.case import transform_sentence_case
>>> transform_sentence_case(['foo bar baz', 'FOO bar. baz Asdf'])
['Foo bar baz', 'Foo bar. Baz asdf']
Or you could use a regex...
\.\s*([a-z])
Captialise the $1
capturing group.
Upvotes: 9