The Python documentation's string methods section is the authoritative reference for everything a str object can do, and you reach it fastest by going to docs.python.org, opening the Library Reference, and finding the "String Methods" section under "Built-in Types." From there, every method is listed alphabetically with a signature, a description, and usually a small example. The trick to using it well is knowing how the page is organised, how to read the signatures, and which methods return a new string versus which ones only test or search. Nothing needs to be installed to read the docs, but having a Python interpreter open in a second window makes the page far more useful because you can paste each example and see the result immediately.
What You'll Need
- A web browser to reach the official documentation at docs.python.org.
- Python installed locally (from python.org or your operating system's package manager) so you can run the examples in a terminal or REPL.
- Basic familiarity with creating a string variable, for example
s = "Hello World". - Optional: the built-in
help()function, which prints the same docstrings offline when you typehelp(str).
Step-by-Step
- Open the official docs. Go to docs.python.org and choose your Python version from the version selector if one is shown. Documentation for different versions can differ slightly in wording and in which methods exist, so match the version you actually run. You can confirm your version by typing
python --versionin a terminal. - Navigate to the String Methods page. The path is Library Reference, then "Built-in Types," then the "String Methods" subsection. The page lists every method on
strin alphabetical order, fromcapitalize()throughzfill(). Labels and layout can shift between documentation versions, but the section name stays the same. - Read the signature before the description. Each entry begins with the method name and its parameters in parentheses. Square brackets mean the argument is optional. For example,
str.split(sep=None, maxsplit=-1)tells you that callingsplit()with no arguments is valid and that the separator defaults to any whitespace. - Note the return type. Some methods return a new string (
upper(),replace(),strip()), some return a list (split(),splitlines()), some return a boolean (startswith(),isnumeric()), and some return an integer index (find(),count()). Knowing this prevents the most common beginner error of assigning a boolean and then calling string methods on it. - Test the example in a REPL. Open a terminal and type
pythonto start the interactive prompt. Paste the example from the docs, then change one argument to see how the output shifts. This is the single fastest way to internalise what an optional parameter does. - Use the search box for a specific method. If you know the name, such as
partition, use your browser's find function (Ctrl+F on Windows and Linux, Command+F on macOS) rather than scrolling. The alphabetical order makes scanning predictable once you know the first letter. - Follow the cross-references. Many entries link to related material, such as the formatting mini-language for
format()and f-strings, or the regular expression module for pattern-based replacement. Those links are part of the documentation and often answer the follow-up question you are about to have. - Fall back to
help()offline. In a Python session,help(str.strip)prints the docstring for that single method, andhelp(str)prints the whole list. This works without a browser and reflects the exact version you have installed.
Common Mistakes
The biggest one is expecting a method to change the original string. Strings are immutable in Python, so s.upper() returns a new string and leaves s untouched. You must reassign, as in s = s.upper(), or the result is discarded.
Another frequent slip is confusing find() with index(). Both search for a substring, but find() returns -1 when the substring is absent while index() raises a ValueError. Choosing the wrong one turns a simple check into a crash.
People also misread optional parameters. Passing a separator to split() changes behaviour completely compared with the default whitespace splitting, and passing an empty string raises an error. Read the signature line rather than assuming.
Finally, do not confuse methods that look similar in name. strip() removes characters from both ends, not from the middle, and it takes a set of characters rather than a substring, so strip("ab") removes any leading or trailing a or b characters, which surprises many readers.
Tips
Bookmark the String Methods page directly rather than navigating each time; it is one of the most revisited pages in the reference. Keep a REPL open beside it so every example is one paste away.
When you are unsure whether a method exists in your Python version, check with hasattr(str, "methodname") before relying on it in code that has to run on older interpreters.
Read the "See also" notes at the end of entries. They often point to the more powerful tool for the job, such as str.format() versus f-strings, or re.sub() versus repeated replace() calls.
Prefer methods over hand-written loops. The docs describe behaviour that is already implemented efficiently, and using startswith() or endswith() with a tuple of prefixes is clearer than chaining several comparisons.
Troubleshooting
If an example from the docs raises an error on your machine, first check your Python version against the version selector on the page. Methods added in newer releases will fail on older interpreters with an AttributeError.
If a method seems to do nothing, you probably did not assign the result. Print the return value directly to confirm what it produced.
If a search method returns -1, the substring genuinely is not present; check for trailing spaces or case differences, since string matching is case-sensitive unless you normalise both sides first.
If the documentation page will not load, use help(str) in a local session, which contains the same descriptions offline. If a method behaves differently from what you expect, copy the exact example from the docs into your REPL and compare the output character by character.
Frequently Asked Questions
Where exactly is the String Methods page?
It sits in the Library Reference under "Built-in Types," in the section titled "String Methods." Searching the docs site for "string methods" also lands there.
Do string methods modify the original string?
No. Python strings are immutable, so every method returns a new value and the original is unchanged. You must reassign the result to keep it.
What is the difference between find() and index()?
find() returns -1 when the substring is missing, while index() raises a ValueError. Use find() for a safe check and index() when absence should stop the program.
Can I read the docs without internet access?
Yes. The help() function prints docstrings built into your installation, and many Python distributions include an offline copy of the documentation.
Why does split() behave differently with no arguments?
With no argument it splits on any run of whitespace and discards empty strings, which is usually what you want for user input. Passing an explicit separator changes that behaviour.
Are method names case-sensitive?
Yes. Python identifiers are case-sensitive, so upper() works and Upper() raises an AttributeError.