Convert string to title case in Python Last Updated : 07 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to convert the string to a title case in Python. The str.title() method capitalizes the first letter of every word. Python s = "geeks for geeks" result = s.title() print(result) OutputGeeks For Geeks Explanation:The s.title() method converts the string "python is fun" to title case.capitalizing the first letter of each word and converting the rest to lowercase, resulting in "Geeks For Geeks".Table of ContentUsing the string.capwords() FunctionUsing a List ComprehensionUsing the string.capwords() The string.capwords() function splits the text into words capitalizes the first letter of each word, and joins them back together with spaces. Python import string s = "geeks for geeks" # Use the capwords() function to capitalize the first letter of each word result = string.capwords(s) print(result) OutputGeeks For Geeks Explanation:The string.capwords() function splits the input string "geeks for geeks" into words based on spaces, capitalizes the first letter of each word, and converts the rest to lowercase.Finally, it joins the words back together with spaces, resulting in "Geeks For Geeks"Using a List ComprehensionManually capitalize each word in a string using a list comprehension and the str.capitalize() method. Python s = "geeks for geeks" # Split the string into a list of words, capitalize each word, #and join them back with spaces result = " ".join(word.capitalize() for word in s.split()) print(result) OutputGeeks For Geeks ExplanationThe s.split() method splits the string "geeks for geeks" into a list of words: ["geeks", "for", "geeks"]. Each word is then capitalized using word.capitalize() inside a generator expression.The " ".join() method combines the capitalized words back into a single string with spaces, resulting in "Geeks For Geeks". Comment More infoAdvertise with us Next Article numpy string operations | title() function Y Yash_R Follow Improve Article Tags : Python python-string Python-string-functions Practice Tags : python Similar Reads Python - Convert Snake case to Pascal case Converting a string from snake case to Pascal case involves transforming a format where words are separated by underscores into a single string where each word starts with an uppercase letter, including the first word. Using title() This method converts a snake case string into pascal case by replac 3 min read Python String Title method title() method in Python is a simple way to convert a string to a title case, where the first letter of each word is capitalized and all other letters are lowercase. Let's understand with the help of an example:Pythona = "hello geek" # Converts string to title case b = a.title() print(b)OutputHello 2 min read Python String casefold() Method Python String casefold() method is used to convert string to lowercase. It is similar to the Python lower() string method, but the case removes all the case distinctions present in a string. Python String casefold() Method Syntax Syntax: Â string.casefold() Parameters: The casefold() method doesn't t 1 min read numpy string operations | title() function numpy.core.defchararray.title(arr): function is used to Return element-wise title cased version of string or unicode.Title case words start with uppercase characters, all remaining cased characters are lowercase. Parameters: arr : [ array_like ] Input array which may be str or unicode. Returns : [nd 1 min read Python | Pandas Series.str.lower(), upper() and title() Python is a great language for data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages, making importing and analyzing data much easier. Python has some inbuilt methods to convert a string into a lower, upper, or Camel case. But th 4 min read Python Capitalize First Letter of Every Word in String There are different ways to capitalize the first letter of every word in a string using Python. We will cover methods such as using str.capitalize(), loops and regular expressions to achieve this text formatting task.Using str.title()str.title() method in Python converts the first character of each 3 min read Like