Python String Methods

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 15 Tutorials
Reference Index

What You’ll Find Here

Python strings ship with dozens of built-in methods for formatting text, searching substrings, validating input, and converting data. This page is your central hub: browse every essential str method, jump to full tutorials where available, and learn patterns that work in real programs.

01

Full Tutorials

15 methods with examples.

02

Quick Reference

All methods by category.

03

Searchable

Filter by method name.

04

Immutable

Methods return new values.

05

Beginner Tips

Usage patterns included.

06

Start Here

capitalize() → isdigit().

Introduction

In Python, a string (str) is a sequence of characters. You call methods on a string variable using dot notation: text.strip(), name.upper(), email.find("@"). These methods make everyday text tasks—cleaning user input, building messages, checking file extensions—fast and readable.

💡
Beginner Tip

String methods never change the original string. Always use or assign the return value: clean = raw.strip(), not just raw.strip() alone when you need the result later.

String Methods Index

Search by method name or browse by category. Cards marked Tutorial link to full guides with examples, output, and FAQs.

Case & Formatting

10 methods

Change letter case, pad text, and align strings inside a fixed width.

capitalize()
Tutorial

First character upper, rest lower.

casefold()
Tutorial

Aggressive lowercase for comparisons.

center()
Tutorial

Center text within a width.

lower()
Reference

Return an all-lowercase copy.

upper()
Reference

Return an all-uppercase copy.

title()
Reference

Capitalize the first letter of each word.

swapcase()
Reference

Swap upper- and lowercase letters.

ljust()
Reference

Left-align with padding.

rjust()
Reference

Right-align with padding.

zfill()
Reference

Pad with leading zeros.

Search & Check

8 methods

Locate substrings, count occurrences, and test prefixes or suffixes.

find()
Tutorial

Index of substring, or -1.

index()
Tutorial

Index of substring, or ValueError.

count()
Tutorial

Count how many times sub appears.

endswith()
Tutorial

True if string ends with suffix.

startswith()
Reference

True if string starts with prefix.

replace()
Reference

Swap one substring for another.

rfind()
Reference

Last index of substring, or -1.

rindex()
Reference

Last index of substring, or error.

Split, Join & Whitespace

10 methods

Break strings apart, merge iterables, and trim extra space.

expandtabs()
Tutorial

Replace tabs with spaces.

split()
Reference

Split into a list by delimiter.

rsplit()
Reference

Split from the right.

splitlines()
Reference

Split on line boundaries.

partition()
Reference

Split into three parts once.

rpartition()
Reference

Partition from the right.

join()
Reference

Join iterable with separator.

strip()
Reference

Remove leading and trailing space.

lstrip()
Reference

Remove leading whitespace.

rstrip()
Reference

Remove trailing whitespace.

Validation (is* methods)

11 methods

Return True or False to validate character content.

isalnum()
Tutorial

Letters and digits only.

isalpha()
Tutorial

Letters only.

isdecimal()
Tutorial

Strict decimal digits.

isdigit()
Tutorial

Digit characters only.

isidentifier()
Reference

Valid Python identifier.

islower()
Reference

All cased chars are lowercase.

isupper()
Reference

All cased chars are uppercase.

istitle()
Reference

Title-cased words.

isspace()
Reference

Whitespace characters only.

isnumeric()
Reference

Numeric characters.

isprintable()
Reference

All characters printable.

Encoding & Templates

4 methods

Build formatted messages and convert text to bytes.

🚀 Usage Tips

  • Chain methods — combine steps in one line: user_input.strip().lower().
  • Know optional parameters — many methods accept start, end, or width; check each tutorial for defaults.
  • Handle errors — use try/except with index(); check -1 from find().
  • Pick the right checkisdecimal() for strict digits, isalnum() for usernames, endswith() for file types.
  • Read the tutorial — each linked method page includes syntax, examples, and a quick reference table.

📝 How to Call a String Method

Every string method follows the same pattern:

variable.method_name(arguments)

Common Patterns

GoalExample
Format display textlabel.capitalize()
Find a substringtext.find("error")
Build a message"Hello, {name}".format(name="Mari")
Validate inputpin.isdigit()
Check file extensionfilename.endswith(".pdf")

Conclusion

Python string methods cover almost every text task you will encounter as a beginner—from tidying user input to searching logs and formatting output. Use this index to find the right method quickly, then open the full tutorial for syntax, examples, and best practices.

Start with capitalize() if you are new to string methods, then explore find(), format(), and the is* validation methods.

❓ Frequently Asked Questions

String methods are built-in functions you call on str objects using dot notation, such as text.upper() or text.find("hello"). They help you format, search, validate, and transform text without writing low-level character loops.
No. Python strings are immutable. Methods always return a new string (or a boolean/integer for checks like endswith() or find()). Assign the result to a variable if you need to keep it.
Both locate a substring. find() returns -1 when missing; index() raises ValueError. Use find() when absence is normal; use index() when a missing substring means invalid input.
Both check digit-only strings. isdecimal() is stricter and allows only base-10 decimal digits. isdigit() also accepts some Unicode compatibility digits that isdecimal() rejects.
Yes. Because each method returns a str (or you can chain on the result), you can write readable pipelines like input("Name: ").strip().title().
Start with capitalize(), find(), format(), and the is* validation methods. They cover formatting, searching, templating, and input checks—the most common everyday tasks.
Did you know?

Tip: Python strings are immutable. Methods like upper() and replace() return a new string—they never change the original.

Start Your First String Method Tutorial

Open the capitalize() guide—syntax, five examples, and a quick reference cheat sheet.

capitalize() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

19 people found this page helpful