Here is my code:
def fix_capitalization(usrStr):
newString = ''
wordList = []
numLetters = 0
for s in usrStr.split('. '):
if s[0].isupper():
s = s.capitalize()
s = s.replace(' i ', " I ")
wordList.append(s)
if s.islower():
s = s.capitalize()
s = s.replace(' i ', " I ")
wordList.append(s)
numLetters += 1
if s[0].islower():
s = s.capitalize()
s = s.replace(' i ', " I ")
wordList.append(s)
numLetters += 1
newString = '. '.join(wordList)
return newString, numLetters
i want some water. he has some. maybe he can give me some. i think I will ask.
maybe
I want some water. He has some. Maybe he can give me some. I think I will ask.
I want some water. He has some. maybe he can give me some. I think I will ask.
maybe
.
In for loop: First find the index of non-space character. Then replace s[0] with s[index].