I run into this medium post today – “How To Capitalize All Words in a String in Python“.
It explains how to convert “hello world” to “Hello World” but it does it the hard way. An easier solution would be to use title function.
x = "hello world" print(x.title()) #Hello World
See more documentation here
2 thoughts on “How To Capitalize All Words in a String in Python – The Easy way”
“Doesn’t behave as you’d hope”
“Doesn’T Behave As You’D Hope”
The version he gives does work although it assumes that you don’t mistype and leave no space after a period.
You are right, thank you for your comment.