I've been solving a challenge of fixing the input paragraph into properly capitalized letters. This is my code:
return ''.join([in_text[0].upper()] + [in_text[i].lower() if in_text[i-1] != '.' or in_text[i-2] != ' ' or in_text[i].islower() else in_text[i].upper() for i in range(1, len(in_text))])
However, it was only able to capitalize the first letter of the paragraph and not the first letter of the sentence.
Let's say you had the following paragraph:
As can be seen, the starting word for each sentence is in lowercase.
We can fix this by:
The regex
(?<=[.!?])[\s]*will split when it finds either.,!?[\s]*Here is the code:
Code:
Output: