How To Capitalize All Words in a String in Python – The Easy way

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