Python String Title method Last Updated : 02 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Python a = "hello geek" # Converts string to title case b = a.title() print(b) OutputHello Geek Table of ContentString title() Method SyntaxCreating Proper Names from User InputCleaning Data for DatabaseSyntax of String title()string.title()Parameterstitle() doesn't accept any parameter.Return typestring, converted to title case.Creating Proper Names from User InputWhen we ask users to input their names, we often receive names in lowercase or inconsistent formats. The title() method can help ensure that each part of the name starts with a capital letter. Python user_name = "geeky geek" formatted_name = user_name.title() print(formatted_name) OutputGeeky Geek Cleaning Data for DatabaseWhen importing or processing data for a database, we may encounter strings that need to be formatted in title case. This ensures that data is consistent and easily readable when displayed in a user interface. Python city_name = "noida city" formatted_city_name = city_name.title() print(formatted_city_name) OutputNoida City Comment More infoAdvertise with us Next Article String lower() Method in Python P pawan_asipu Follow Improve Article Tags : Misc Python Python-Library Python-Built-in-functions python-string +1 More Practice Tags : Miscpython Similar Reads String lower() Method in Python lower() method in Python converts all uppercase letters in a string to their lowercase. This method does not alter non-letter characters (e.g., numbers, punctuation). Let's look at an example of lower() method:Pythons = "HELLO, WORLD!" # Change all uppercase letters to lowercase res = s.lower() prin 3 min read Python String lstrip() Method The lstrip() method removes leading whitespace characters from a string. We can also specify custom characters to remove from the beginning/starting of the string.Let's take an example to remove whitespace from the starting of a string.Pythons = " Hello Python!" res = s.lstrip() print(res)OutputHell 2 min read Python String partition() Method In Python, the String partition() method splits the string into three parts at the first occurrence of the separator and returns a tuple containing the part before the separator, the separator itself, and the part after the separator. Let's understand with the help of an example:Pythons = "Geeks gee 3 min read Python String replace() Method The replace() method replaces all occurrences of a specified substring in a string and returns a new string without modifying the original string.Letâs look at a simple example of replace() method.Pythons = "Hello World! Hello Python!" # Replace "Hello" with "Hi" s1 = s.replace("Hello", "Hi") print( 2 min read Python String rfind() Method Python String rfind() method returns the rightmost index of the substring if found in the given string. If not found then it returns -1.ExamplePythons = "GeeksForGeeks" print(s.rfind("Geeks"))Output8 Explanationstring "GeeksForGeeks" contains the substring "Geeks" twice.rfind() method starts the sea 4 min read Python String rindex() Method Python String rindex() method returns the highest index of the substring inside the string if the substring is found. Otherwise, it raises ValueError.Let's understand with the help of an example:Pythons = 'geeks for geeks' res= s.rindex('geeks') print(res)Output10 Note: If start and end indexes are 2 min read Python String rpartition() Method String rpartition() method in Python is a powerful tool for splitting a string into three parts, based on the last occurrence of a specified separator. It provides an efficient way to handle text parsing when we want to divide strings from the rightmost delimiter. Let us start with a simple example: 4 min read Python String rsplit() Method Python String rsplit() method returns a list of strings after breaking the given string from the right side by the specified separator. It's similar to the split() method in Python, but the difference is that rsplit() starts splitting from the end of the string rather than from the beginning. Exampl 3 min read Python String rstrip() Method The rstrip() method removes trailing whitespace characters from a string. We can also specify custom characters to remove from end of string.Let's take an example to remove whitespace from the ends of a string.Pythons = "Hello Python! " res = s.rstrip() print(res)OutputHello Python! Syntax of rstrip 2 min read Python String splitlines() method In Python, the splitlines() method is used to break a string into a list of lines based on line breaks. This is helpful when we want to split a long string containing multiple lines into separate lines. The simplest way to use splitlines() is by calling it directly on a string. It will return a list 2 min read Like