Python String Functions - Complete Guide
This document contains commonly used Python string functions (methods) with short explanations.
• capitalize() – Capitalizes first character
• casefold() – Converts string to lowercase (stronger than lower)
• center(width) – Centers string
• count() – Counts occurrences
• encode() – Encodes string
• endswith() – Checks ending
• expandtabs() – Expands tab spaces
• find() – Finds position
• format() – Formats string
• format_map() – Formats using mapping
• index() – Finds position (error if not found)
• isalnum() – Checks alphanumeric
• isalpha() – Checks alphabet
• isascii() – Checks ASCII characters
• isdecimal() – Checks decimal
• isdigit() – Checks digits
• isidentifier() – Checks valid identifier
• islower() – Checks lowercase
• isnumeric() – Checks numeric
• isprintable() – Checks printable
• isspace() – Checks whitespace
• istitle() – Checks title case
• isupper() – Checks uppercase
• join() – Joins iterable
• ljust() – Left justify
• lower() – Converts to lowercase
• lstrip() – Removes left spaces
• maketrans() – Creates translation table
• partition() – Splits into 3 parts
• removeprefix() – Removes prefix
• removesuffix() – Removes suffix
• replace() – Replaces substring
• rfind() – Finds from right
• rindex() – Finds from right (error if not found)
• rjust() – Right justify
• rpartition() – Splits from right
• rsplit() – Splits from right
• rstrip() – Removes right spaces
• split() – Splits string
• splitlines() – Splits lines
• startswith() – Checks starting
• strip() – Removes spaces both sides
• swapcase() – Swaps case
• title() – Title case
• upper() – Converts to uppercase
• zfill() – Pads with zeros