Python string methods are built-in functions that allow you to manipulate and analyze strings. Since strings in Python are immutable, these methods return a new string rather than modifying the original.

Core String Methods

  • Case Manipulation:

    • upper(): Converts all characters to uppercase.

    • lower(): Converts all characters to lowercase.

    • capitalize(): Capitalizes the first character and makes the rest lowercase.

    • title(): Capitalizes the first letter of each word.

    • swapcase(): Swaps the case of all characters.

    • casefold(): More aggressive than lower(); used for caseless matching.

  • Search and Find:

    • find(): Returns the index of the first occurrence of a substring (returns -1 if not found).

    • index(): Similar to find(), but raises a ValueError if not found.

    • rfind(): Returns the highest index of a substring.

    • rindex(): Similar to rfind(), but raises an exception if not found.

    • count(): Returns the number of times a substring appears.

  • Checking Conditions (Boolean):

    • isalnum(): Returns True if all characters are alphanumeric.

    • isalpha(): Returns True if all characters are alphabetic.

    • isdigit(): Returns True if all characters are digits.

    • isnumeric(): Returns True if all characters are numeric (includes Unicode numerals).

    • isidentifier(): Checks if the string is a valid Python identifier.

    • islower(), isupper(): Check if all characters are lowercase or uppercase.

    • isspace(): Returns True if the string contains only whitespace.

    • istitle(): Returns True if the string is title-cased.

    • isprintable(): Returns True if all characters are printable.

  • Trim and Align:

    • strip(): Removes leading and trailing whitespace (or specified characters).

    • lstrip(): Removes leading whitespace.

    • rstrip(): Removes trailing whitespace.

    • center(width, fillchar): Centers the string within a specified width using a fill character.

    • ljust(width, fillchar): Left-aligns the string.

    • rjust(width, fillchar): Right-aligns the string.

    • expandtabs(tabsize): Replaces tab characters with spaces.

  • Split and Join:

    • split(sep): Splits the string into a list using a separator (default is whitespace).

    • rsplit(sep): Splits from the right.

    • splitlines(): Splits the string at line boundaries.

    • join(iterable): Joins elements of an iterable into a single string with the string as a separator.

  • Replace and Modify:

    • replace(old, new, count): Replaces occurrences of a substring with another.

    • partition(sep): Splits the string into three parts at the first occurrence of a separator.

    • rpartition(sep): Splits at the last occurrence of a separator.

    • removeprefix(prefix): Removes a prefix if present (Python 3.9+).

    • removesuffix(suffix): Removes a suffix if present (Python 3.9+).

  • Encoding and Translation:

    • encode(encoding): Encodes the string using the specified encoding.

    • maketrans(x, y, z): Creates a translation table.

    • translate(table): Applies a translation table to the string.

  • Starts/Ends With:

    • startswith(prefix): Returns True if the string starts with the given prefix.

    • endswith(suffix): Returns True if the string ends with the given suffix.

  • Padding:

    • zfill(width): Pads the string with zeros on the left to fill the specified width.

For full details and examples, refer to the official Python documentation: Built-in Types — Python 3.14.3 documentation.

🌐
W3Schools
w3schools.com › python › python_ref_string.asp
Python String Methods
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Python has a set of built-in methods that you can use on strings.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
2 weeks ago - The methods that add, subtract, or rearrange their members in place, and don’t return a specific item, never return the collection instance itself but None. Some operations are supported by several object types; in particular, practically all objects can be compared for equality, tested for truth value, and converted to a string ...
Discussions

Why do widely used frameworks in python use strings instead of enums for parameters?
I’d guess age and momentum? I don’t think enums were used nearly as much before type hinting was more common. More on reddit.com
🌐 r/Python
108
225
October 19, 2024
Should I use ' or " in Python?
They are interchangeable most of the time. Sometimes you want to print a string with one of those characters in it, right? print("I'm hungry") works but print('I'm hungry') does not; perhaps you can see why. More on reddit.com
🌐 r/learnpython
56
68
February 25, 2017
Why doesn't method chaining work in Python?
In Python, methods or functions which have side effects and modify the object in place (like append() or sort()) explicitly return None. This is to prevent any confusion with the functional style (like sorted()), in which return values are newly allocated objects and the original is unchanged. In this case, a "chained" version would just be test = test + [1] + [2] More on reddit.com
🌐 r/Python
19
0
August 25, 2015
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-methods
Python String Methods - GeeksforGeeks
July 23, 2025 - Python string methods is a collection of in-built Python functions that operates on strings.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations
2 days ago - As in string literals, it expands to the named Unicode character (e.g. '\N{EM DASH}'). The module defines several functions, constants, and an exception. Some of the functions are simplified versions of the full featured methods for compiled regular expressions.
🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. It is just a wrapper that calls vformat(). Changed in version 3.7: A format string argument is now positional-only.
🌐
CodeWithHarry
codewithharry.com › tutorial › python-string-methods
String Methods | Python Tutorial | CodeWithHarry
The isupper() method returns True if all the characters in the string are upper case, else it returns False. ... The replace() method can be used to replace a part of the original string with another string. ... Python is a Interpreted Language.
🌐
Google
developers.google.com › google for education › python › python strings
Python Strings | Python Education | Google for Developers
Characters and substrings can be accessed using zero-based indexing and the handy slice syntax. Python provides string methods for common operations like changing case, removing whitespace, and searching.
🌐
Medium
nathanrosidi.medium.com › python-string-methods-here-is-how-to-master-them-816fc34ac2db
Python String Methods: Here is How to Master Them | by Nathan Rosidi | Medium
August 13, 2024 - Python’s string methods for searching and replacing are like a well-trained search-and-rescue squad, able to quickly locate and alter textual content with tremendous accuracy. When it is necessary to determine the position of a substring in a string, the method find is useful.
Find elsewhere
🌐
Codecademy
codecademy.com › learn › learn-python-3 › modules › learn-python3-strings › cheatsheet
Learn Python 3: Strings Cheatsheet | Codecademy
The string method .title() returns the string in title case. With title case, the first character of each word is capitalized while the rest of the characters are lowercase. ... If no argument is passed, the default behavior is to split on whitespace. If an argument is passed to the method, that value is used as the delimiter on which to split the string. ... The Python string method .find() returns the index of the first occurrence of the string passed as the argument.
🌐
YouTube
youtube.com › watch
String methods in Python are easy! 〰️
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
Programiz
programiz.com › python-programming › methods › string
Python String Methods | Programiz
Become a certified Python programmer. Try Programiz PRO! ... A string is a sequence of characters enclosed in quotation marks. In this reference page, you will find all the methods that a string object can call.
🌐
Cisco
ipcisco.com › home › python string methods
Python String Methods | lower | upper | format | strip | join method⋆
March 12, 2021 - Let’s Show this python string method with an example: msg = "welcome to python course!" x = msg.capitalize() print (x) This code will return with the below sentence with upper case first character. Welcome to python course! You can practice below! If we would like to convert all the words in a string to upper case, we use python title() mehod.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-string-functions
Python String Functions | DigitalOcean
August 3, 2022 - Python String is immutable, so all these functions return a new string and the original string remains unchanged. There are many functions to operate on String. However, it’s not feasible to remember all of them. So here I am dividing them into different categories.
🌐
StrataScratch
stratascratch.com › blog › python-string-methods-here-is-how-to-master-them
Python String Methods: Here is How to Master Them - StrataScratch
April 17, 2024 - Python’s string methods for searching and replacing are like a well-trained search-and-rescue squad, able to quickly locate and alter textual content with tremendous accuracy. When it is necessary to determine the position of a substring in a string, the method find is useful.
🌐
Udemy
blog.udemy.com › home › the 23 most common python string methods and functions
The 23 Most Common Python String Methods and Functions - Udemy Blog
March 11, 2022 - Learn Python like a Professional ... Pierian Training Explore Course · Python string methods are functions designed to validate and format Python strings....
🌐
Career Karma
careerkarma.com › blog › python › python string methods: step-by-step guide
Python String Methods: Step-By-Step Guide | Career Karma
December 1, 2023 - In addition, you can use the capitalize() method to capitalize the first character of a string, and the title() method to capitalize the first letter of every word in a string. These functions are useful if you want to compare strings and want to keep the cases of those strings consistent. This is important because comparisons in Python are case sensitive.
🌐
Tutorialspoint
tutorialspoint.com › home › python › python string methods
Python String Methods
February 21, 2009 - Python's built-in str class defines different methods. They help in manipulating strings. Since string is an immutable object, these methods return a copy of the original string, performing the respective processing on it.
🌐
PrepBytes
prepbytes.com › home › python › python string methods and functions
Python String Methods and Functions
June 19, 2023 - Python provides an extensive set of string methods and functions that allow developers to perform various operations, such as searching, modifying, formatting, and analyzing strings.
🌐
Scaler
scaler.com › topics › python › string-methods-python
Python String Methods - Scaler Topics
September 17, 2021 - Learn about string methods Python by Scaler Topics. Python string methods are built-in sets of methods that can be used on strings.
🌐
iO Flood
ioflood.com › blog › python-string-methods
Python String Methods: Ultimate Functions Guide
December 11, 2023 - Python’s string methods are powerful tools that can make your coding tasks a lot simpler. Let’s start with some of the most basic yet essential string methods. The lower() method converts all uppercase characters in a string to lowercase, and the upper() method does the opposite – it converts all lowercase characters to uppercase.