this is the assignment
Implement the fix_capilization() function. fix_capilization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capilization() also returns the number of letters that have been capitalized. Call fix_capilization() in the print_menu() function, and then output the number of letters capitalized and the edited string. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string.
Ex: Number of letters capitalized: 3
Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!
this is my code
def fix_capitalization(userString):
capitalCount = 0
editedString = ""
for cap in userString.split("."):
cap = cap.strip(" ").capitalize()
capitalCount += 1
editedString += cap + ". "
return capitalCount, editedString
I am having a hard time concocting it together. I think I am needing to add a split with other punctuations besides the period, and when I concoct it together it just doesn't come out right. If I add the ". " it adds a period even on sentences that have an exclamation points, and if I get rid of the period, it just adds spaces and get's rid of the punctuation. What am I doing wrong?