Suppose I have a string x, defined as follows:


my_string = "wello world !! monty python says hi! where do you wanna go today."

What’s the correct Python command to capitalize this string: my_string?

Simple, use:

my_string.capitalize()

 

How to capitalize each word in the string?

Simple again, use:

my_string.title()

 

Advertisements