This should be easy but somehow I\'m not quite getting it.
My assignment is:
Write a function sentenceCapitalizer that has one parameter of type
I did not use 'split' but just while loop instead. Here is my code.
my_string = input('Enter a string: ')
new_string = ''
new_string += my_string[0].upper()
i = 1
while i < len(my_string)-2:
new_string += my_string[i]
if my_string[i] == '.' or my_string[i] == '?' or my_string[i] == '!':
new_string += ' '
new_string += my_string[i+2].upper()
i = i+3
else:
if i == len(my_string)-3:
new_string += my_string[len(my_string)-2:len(my_string)]
i = i+1
print(new_string)
Here is how it works:
Enter a string: hello. my name is Joe. what is your name?
Hello. My name is Joe. What is your name