title()

Converts the first character of each word to uppercase and the rest of the characters in each word to lowercase, such that the resulting string conforms with the rules for a title.

Example

Python
str = 'hello wORLD!'
print(str.title())

Output

Hello World!