⬅ Previous TopicPython Built-in Functions










Python String Methods
Python String Methods
In Python, strings are one of the most commonly used data types. To help you work with text easily, Python gives you many built-in string methods.
These methods let you change, check, or find things in strings without writing a lot of extra code.
List of Python String Methods
Below is a complete list of all string methods in Python, explained simply so even beginners can understand.
Method | Description |
---|---|
capitalize() | Converts the first character to upper case |
casefold() | Converts string into lower case (more aggressive than lower()) |
center() | Returns a centered string with padding |
count() | Counts how many times a value appears in the string |
encode() | Encodes the string using a specified encoding (like UTF-8) |
endswith() | Checks if the string ends with the specified value |
expandtabs() | Sets the tab size (replaces tabs with spaces) |
find() | Returns the first position of a value, or -1 if not found |
format() | Formats strings using placeholders |
format_map() | Formats strings using a dictionary map |
index() | Like find(), but raises an error if not found |
isalnum() | Returns True if all characters are letters or numbers |
isalpha() | Returns True if all characters are letters |
isascii() | Returns True if all characters are ASCII |
isdecimal() | Returns True if all characters are decimals |
isdigit() | Returns True if all characters are digits |
isidentifier() | Returns True if the string is a valid Python identifier |
islower() | Returns True if all characters are lowercase |
isnumeric() | Returns True if all characters are numeric |
isprintable() | Returns True if all characters can be printed |
isspace() | Returns True if the string only contains whitespace |
istitle() | Returns True if each word starts with a capital letter |
isupper() | Returns True if all characters are uppercase |
join() | Joins items in an iterable into one string |
ljust() | Returns a left-justified version of the string |
lower() | Converts all characters to lowercase |
lstrip() | Removes leading whitespace or characters |
maketrans() | Creates a translation map for use with translate() |
partition() | Splits the string into 3 parts: before, match, and after |
replace() | Replaces part of the string with another string |
rfind() | Finds the last occurrence of a value |
rindex() | Like rfind(), but raises an error if not found |
rjust() | Returns a right-justified version of the string |
rpartition() | Splits the string from the right into 3 parts |
rsplit() | Splits the string from the right |
rstrip() | Removes trailing whitespace or characters |
split() | Splits the string by a separator |
splitlines() | Splits the string at line breaks |
startswith() | Checks if the string starts with the specified value |
strip() | Removes whitespace or characters from both ends |
swapcase() | Swaps lowercase to uppercase and vice versa |
title() | Converts the first character of each word to uppercase |
translate() | Returns a translated version of the string |
upper() | Converts all characters to uppercase |
zfill() | Fills the string with zeros from the left |
How to Use This List
Click on any method name in our full course (coming soon) to see syntax, examples, and beginner exercises. Practice using them to build your confidence working with strings!
Next Steps
- Start with common ones like
lower()
,replace()
,split()
, andjoin()
- Try combining multiple methods for more advanced text processing
- Use interactive Python shell or an online compiler to test each method
Mastering string methods will help you with file handling, user input processing, and working with APIs or databases. Strings are everywhere in Python!