2021年4月8日星期四

How to capitalize the first letter of a user-inputted string but keep the rest of the string's capitalization

Basically as the title says, I want the sentences of the user input to be capitalized, but not lose their capitalization in the process. The input's supposed to be two sentences that get separated by periods. The code I have here outputs them the sentences, but not joined or keeping the rest of the capitalization.

def main():

 user_input = input("Enter the sentence you would like to be modified!: ").split(". ")   capitalized_sentences = [user_input[0].upper() + user_input[1:] for sentence in user_input]   recombined_sentences = ". ".join(capitalized_sentences)  
https://stackoverflow.com/questions/67013404/how-to-capitalize-the-first-letter-of-a-user-inputted-string-but-keep-the-rest-o April 09, 2021 at 08:10AM

没有评论:

发表评论