Tag

split

1 guide filed under this subject.

How To Capitalize First Letter Of Every Word In Python (One-Liner)

How do you capitalize the first letter of each word in a string using Python? To capitalize the first letter of every word in Python using one line of code enter the following: " ".join([x.capitalize() for x in my string.split()]) . Here is an example demonstrating how the code works in the Python REPL: As you can see from the above example the output produces a string with each character…

Read guide