String
Strings in Python are immutable sequences of Unicode code points. Python provides a rich set of string methods for text processing. The guide walks through Case Conversion, Searching & Counting, Splitting & Joining, Stripping & Padding. `str.upper()`, `str.lower()`, `str.title()`, `str.capitalize()`, and `str.swapcase()` change string casing. `str.casefold()` is more aggressive than `lower()` for certain locales. `str.find()`, `str.rfind()`, `str.index()`, `str.count()`, `str.startswith()`, and `str.endswith()` search within strings. `find()` returns -1 on failure, `index()` raises ValueError. `str.split()`, `str.rsplit()`, `str.splitlines()`, and `str.partition()` divide strings. `str.join()` concatenates a list of strings with a separator. The guide is organized into 4 sections that build on each other, each pairing a prose explanation with runnable code. Browse the individual functions covered by this guide in the String Methods category. Key APIs covered include str.upper(), str.lower(), str.capitalize(), str.title(), str.strip(), str.lstrip(). Related guides: builtins, list, dict, os, re.