🌐
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.
🌐
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 Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... Python has a set of built-in methods that you can use on strings.
Discussions

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
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
March 16, 2016
Time Complexities of Various Operations in Python
I just asked a pypy developer if there's any difference between CPython and PyPy in regards to these algorithms. This is the answer: < arigato> it's basically the same algorithms < arigato> plus tons of tweaks that don't change the amortised complexity More on reddit.com
🌐 r/Python
17
54
January 12, 2012
Algorithm complexity with strings and slices

The python page on time-complexity shows that slicing lists has a time-complexity of O(k), where "k" is the length of the slice. That's for lists, not strings, but the complexity can't be O(1) for strings since the slicing must handle more characters as the size is increased. At a guess, the complexity of slicing strings would also be O(k). We can write a little bit of code to test that guess:

import time

StartSize = 2097152

size = StartSize
for _ in range(10):
    # create string of size "size"
    s = '*' * size

    # now time reverse slice
    start = time.time()
    r = s[::-1]
    delta = time.time() - start

    print(f'Size {size:9d}, time={delta:.3f}')

    # double size of the string
    size *= 2

This uses a simple method of timing. Other tools exist, but this is simple. When run I get:

$ python3 test.py
Size   2097152, time=0.006
Size   4194304, time=0.013
Size   8388608, time=0.024
Size  16777216, time=0.050
Size  33554432, time=0.098
Size  67108864, time=0.190
Size 134217728, time=0.401
Size 268435456, time=0.808
Size 536870912, time=1.610
Size 1073741824, time=3.192

which shows the time doubles when doubling the size of the string for each reverse slice. So O(n) (k == n for whole-string slicing).

Edit: spelling.

More on reddit.com
🌐 r/learnpython
4
3
December 1, 2019
🌐
Programiz
programiz.com › python-programming › methods › string
Python String Methods | Programiz
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.
🌐
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.
🌐
Python Engineer
python-engineer.com › posts › string-methods-python
31 essential String methods in Python you should know - Python Engineer
December 19, 2021 - s = 'Arthur: three!'.lstrip('Arthur: ') # 'ee!' s = 'Arthur: three!'.removeprefix('Arthur: ') # 'three!' s = 'HelloPython'.removesuffix('Python') # 'Hello' Return a copy of the string with all occurrences of substring old replaced by new. s = ' \n \t hello\n'.replace('\n', '') # ' \t hello' If we want to replace a specific pattern with another character, we can use the re module and use a regular expression. import re s = "string methods in python" s2 = re.sub("\s+" , "-", s) # 'string-methods-in-python'
🌐
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.
🌐
SitePoint
sitepoint.com › blog › programming › python string methods, with examples
Python String Methods, with Examples — SitePoint
November 15, 2024 - In this article, we’ll cover useful Python string methods for manipulating string (str) objects — such as joining, splitting and capitalizing. Each method described in this article will include an explanation with a relevant example.
Find elsewhere
🌐
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.
🌐
Python
docs.python.org › 3 › library › string.html
Common string operations — Python 3.14.6 documentation
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.
🌐
Python Morsels
pythonmorsels.com › string-methods
Python's String Methods - Python Morsels
August 29, 2022 - If you need any of those features, you'll want to look into regular expressions (specifically the re.split function). Need to replace one substring (a string within a string) with another? That's what the string replace method is for! >>> message = "JavaScript is lovely" >>> message.replace("JavaScript", "Python") 'Python is lovely'
🌐
Medium
medium.com › latinxinai › mastering-string-methods-in-python-1e847ca91d7
A Guide to Python String Methods. Strings play a fundamental role in… | by Pedro Henrique Salles | LatinXinAI | Medium
September 28, 2023 - Strings are often used to represent textual information in programming. To improve string manipulation in Python, let’s start with three essential methods: capitalize(), upper(), and lower().
🌐
Tutorialspoint
tutorialspoint.com › python › python_string_methods.htm
Python - String Methods
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.
🌐
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.
🌐
Towards Data Science
towardsdatascience.com › home › latest › 15 must-know python string methods
15 Must-Know Python String Methods | Towards Data Science
January 19, 2025 - Both the endswith and startswith methods are case sensitive. ... It replaces a string or a part of it with the given set of characters. ... It splits a string at the occurrences of the specified character and returns a list that contains each part after splitting. ... By default, it splits at whitespace but we can make it based on any character or set of characters. It partitions a string into 3 parts and returns a tuple that contains these parts. txt = "Python is awesome!" txt.partition("is") ('Python ', 'is', ' awesome!')
🌐
W3Schools
w3schools.com › python › python_strings.asp
Python Strings
Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary
🌐
Udemy
blog.udemy.com › home › it & development › software development › the 23 most common python string methods and functions
The 23 Most Common Python String Methods and Functions - Udemy Blog
April 14, 2026 - The Complete Python Bootcamp From Zero to Hero in Python ... Python string methods are functions designed to validate and format Python strings. They are separate from functions or commands.
🌐
Medium
medium.com › @mjawad17 › python-string-methods-a-complete-beginner-friendly-guide-with-examples-cb43e90d773c
Python String Methods: A Complete Beginner-Friendly Guide with Examples | by Muhammad Jawad | Medium
September 27, 2025 - In this article, we’ll explore Python’s string methods, how to use them, and where they can be particularly handy in everyday programming scenarios.
🌐
Runestone Academy
runestone.academy › ns › books › published › py4e-int › strings › methods.html
7.9. String methods — Python for Everybody - Interactive
In this example, we invoke find on word and pass the letter we are looking for as a parameter. The find method can find substrings as well as characters: ... One common task is to remove white space (spaces, tabs, or newlines) from the beginning and end of a string using the strip method:
🌐
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.