Difference between str.capitalize() VS str.title()
title() function in Python is the Python String Method which is used to convert the first character in each word to Uppercase and remaining characters to Lowercase in the string and returns a new string.
Returns: This function returns a string which has first letter in each word is uppercase and all remaining letters are lowercase.
First Output after Title() method is = Geeks For Geeks Converted String is = Geeks For Geeks Original String is = geeKs foR geEks Second Output after Title() method is = Asipu Pawan Kumar Third Output after Title() method is = Stutya Kumari Shaw Fourth Output after Title() method is = 6041
In Python, the capitalize() method converts the first character of a string to a capital (uppercase) letter. If the string has its first character as capital, then it returns the original string.
Returns: This function returns a string which has the first letter in uppercase and all remaining letters in lowercase.
Geeks for geeks GeeksForGeeks
Difference Between title() and capitalize()
The difference between them is that Python string method title() returns a copy of the string in which the first characters of all the words are capitalized whereas the string method capitalize() returns a copy of the string in which just the first word of the entire string is capitalized.
str = "geeks for geeks" str.title() will return Geeks For Geeks str.capitalize() will return Geeks for geeks
My Name Is Xyz Geeks For Geeks My name is xyz Geeks for geeks