GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — Python String Methods - GeeksforGeeks Python String MethodsLast Updated : 16 Jul, 2026 Python string methods are built-in functions that allow us to perform different operations on strings, such as changing letter case, searching text, replacing characters, splitting strings and checking string properties. Since strings are immutable in Python, these methods return a new string instead of modifying the original one. lower()Converts all uppercase characters in a string to lowercase.
In the code below, we will convert a string to lowercase.
Output hello python upper()Converts all lowercase characters in a string to uppercase.
In the code below, we will convert a string to uppercase.
Output HELLO PYTHON capitalize()Converts the first character of the string to uppercase and the remaining characters to lowercase.
In the code below, we will capitalize the first character of a string.
Output Python programming replace()Replaces all occurrences of a substring with another substring.
In the code below, we will replace one word with another.
Output I like Python split()Splits a string into a list using the specified separator.
In the code below, we will split a sentence into words.
Output ['Python', 'is', 'easy'] join()Joins elements of an iterable into a single string.
In the code below, we will join a list of words using a hyphen.
Output Python-is-easy find()Returns the index of the first occurrence of a substring. Returns -1 if the substring is not found.
In the code below, we will find the position of a word.
Output 6 count()Returns the number of times a substring appears in the string.
In the code below, we will count the occurrences of a word.
Output 2 strip()Removes leading and trailing whitespace from a string.
In the code below, we will remove extra spaces.
Output Python startswith()Checks whether a string starts with the specified prefix.
In the code below, we will check whether the string starts with "Py".
Output True More String MethodsThe following built-in string methods are also available in Python:
Comment Explore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |