Python string methods are built-in functions that allow you to manipulate and analyze strings. These methods do not modify the original string but return a new string with the changes applied.

Core String Methods Overview

  • Case Manipulation:

    • capitalize(): Converts the first character to uppercase and the rest to lowercase.

    • upper(): Converts all characters to uppercase.

    • lower(): Converts all characters to lowercase.

    • swapcase(): Swaps uppercase to lowercase and vice versa.

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

  • Search and Find:

    • find(sub[, start[, end]]): Returns the lowest index where substring sub is found; returns -1 if not found.

    • rfind(sub[, start[, end]]): Returns the highest index where substring sub is found.

    • index(sub[, start[, end]]): Similar to find(), but raises a ValueError if not found.

    • count(sub[, start[, end]]): Returns the number of non-overlapping occurrences of sub.

  • Check Conditions:

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

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

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

    • isspace(): Returns True if all characters are whitespace.

    • isupper(), islower(), istitle(): Check case conditions.

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

  • Trim and Align:

    • strip(): Removes leading and trailing whitespace.

    • lstrip(), rstrip(): Remove only leading or trailing whitespace.

    • center(width[, fillchar]): Centers the string in a field of given width.

    • ljust(width[, fillchar]), rjust(width[, fillchar]): Left- or right-align the string.

  • Split and Join:

    • split(sep=None): Splits the string into a list using sep as the delimiter.

    • rsplit(sep=None): Splits from the right.

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

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

  • Replace and Format:

    • replace(old, new[, count]): Replaces occurrences of old with new.

    • format(*args, **kwargs): Formats the string using placeholders.

    • format_map(mapping): Formats using a dictionary.

  • Check Prefix/Suffix:

    • startswith(prefix[, start[, end]]): Returns True if the string starts with prefix.

    • endswith(suffix[, start[, end]]): Returns True if the string ends with suffix.

  • Other Useful Methods:

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

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

    • maketrans(x[, y[, z]]): Returns a translation table for use with translate().

    • translate(table): Translates characters using a mapping table.

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

For full details and examples, refer to the official Python documentation on string methods.

🌐
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
1 week 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

Hard time understanding string formatting in Python
Might be worth noting that the % operator for string formatting is deprecated . If you want to learn the preferred way of doing things, look into the format method instead. Using % and .format() for great good! has a comparison of the 'old' (% style) and 'new' (format) approaches. The new method basically makes caring about %s vs %d irrelevant. What you said is essentially right though, %s just converts what you pass it to a str, as the docs say : 's' - String (converts any Python object using str()). If you try str(5) in IDLE, you'll notice you get the string '5' back. That essentially means you can use %s for anything that will convert with str(x). Using %d conveys your intentions more clearly, but %s will still technically work. Being clear with what your code is trying to do is always a good thing though. More on reddit.com
🌐 r/learnprogramming
11
4
February 4, 2018
String concatenation in Python, which one is the best practice?
I have decided to overwrite my comments. More on reddit.com
🌐 r/learnpython
7
1
October 26, 2018
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
September 3, 2015
Hello, is there a way to mutate strings in Python?
As a technical issue, you cannot "mutate" strings (change them in-place), so string operations always must return a new string if the result differs from the original. And besides the str.replace() method mentioned, there is str.translate() for doing multiple character remappings in one pass, and the codecs module if you really need more flexibility in customized mappings. More on reddit.com
🌐 r/learnpython
8
3
December 20, 2020
🌐
Accreteinfo
accreteinfo.com › home › web development › 10 must-know python string functions
10 Must-Know Python String Functions
April 14, 2023 - In this article, we’ll discuss 10 must-know string functions in Python that can make string handling easy and efficient. The upper() method converts all the characters in a string to uppercase. This method does not modify the original string, but returns a new string with all the characters ...
🌐
LearnPython.com
learnpython.com › blog › python-string-methods
An Overview of Python String Methods | LearnPython.com
This includes common text operations like searching and replacing text, removing whitespace, or counting characters and words. Collectively, these functions are called Python string methods.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations
3 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.
🌐
Internshala
trainings.internshala.com › home › programming › python › python string functions with examples
Python String Functions With Examples
May 16, 2023 - Python has plenty of built-in string methods for modifying and analyzing strings. Python has 51 string functions, including methods to locate, replace, divide, join, format, and compare strings, among others.
Find elsewhere
🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
In addition, the Formatter defines a number of methods that are intended to be replaced by subclasses: ... Loop over the format_string and return an iterable of tuples (literal_text, field_name, format_spec, conversion).
🌐
Programming Historian
programminghistorian.org › en › lessons › manipulating-strings-in-python
Manipulating Strings in Python | Programming Historian
July 17, 2012 - In addition to operators, Python comes pre-installed with dozens of string methods that allow you to do things to strings. Used alone or in combination, these methods can do just about anything you can imagine to strings. The good news is that you can reference a list of String Methods on the ...
🌐
Real Python
realpython.com › python-strings
Strings and Character Data in Python – Real Python
December 22, 2024 - In this tutorial, you'll learn how to use Python's rich set of operators and functions for working with strings. You'll cover the basics of creating strings using literals and the str() function, applying string methods, using operators and built-in functions with strings, and more!
🌐
Dspmuranchi
dspmuranchi.ac.in › pdf › Blog › Python String and python string methods.pdf pdf
Python String and python String methods
A Python string is a sequence of characters. There is a built-in class ‘str’ for ... The fillchar argument is optional. If it's not provided, space is taken as default ... The casefold() method removes all case distinctions present in a string.
🌐
University of Toronto
cs.toronto.edu › ~guerzhoy › c4m_website_archive › workshops › W3 › ListMethodsStringMethods.html
List Methods and String Methods
Notice that the string s hasn't changed. But calling the method upper on string 's', returned the string 'HELLO' which we assigned to variable t.
🌐
W3Schools
w3schools.com › python › ref_string_join.asp
Python String join() Method
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 ... The join() method takes all items in an iterable and joins them into one string.
🌐
CS50
cs50.harvard.edu › python › shorts › string_methods
String Methods - CS50's Introduction to Programming with Python
Interested in a verified certificate or a professional certificate · David J. Malan malan@harvard.edu Facebook GitHub Instagram LinkedIn Reddit Threads Twitter
🌐
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.
🌐
Upgrad
upgrad.com › home › blog › data science › 16+ essential python string methods you should know
Most Essential Python String Methods with Examples
October 30, 2025 - Python string methods give you direct control over how text behaves in your programs. They let you clean, modify, and format strings without writing extra logic. From case conversion and whitespace removal to searching, splitting, and validation, ...
🌐
Pythonspot
pythonspot.com › string-methods
string methods python - Python Tutorial
Methods can be applied to Python strings, where a string is somet text between quotes.
🌐
Pydantic
docs.pydantic.dev › latest › concepts › models
Models - Pydantic Validation
Pydantic can validate data in three different modes: Python, JSON and strings. ... The __init__() model constructor. Field values must be provided using keyword arguments. model_validate(): data can be provided either as a dictionary, or as a model instance (by default, instances are assumed to be valid; see the revalidate_instances setting). Arbitrary objects can also be provided if explicitly enabled. The JSON and strings modes can be used with dedicated methods:
🌐
Codecademy
codecademy.com › docs › python › strings
Python | Strings | Codecademy
August 11, 2025 - Python has special operators to modify strings. For example, + can be used to concatenate strings and * can be used to multiply a string. The keyword in can be used to see if a given character or substring exists in a string: ... The f/F flag (placed before the opening quotation mark). The .format() method (requires manually adding placeholders).
🌐
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.