Immutable sequences with a rich method API — the most-used type in real Python code
String manipulation is everywhere in real code. Python's string methods are expressive enough that one call often replaces a loop — knowing join, split, and find vs index pays off constantly. f-strings are the standard for any output formatting.
Think of a string as a frozen list of characters. You can read any character by index, slice a range out, or iterate over it — but you can never change a character in place. Every method that looks like it modifies the string actually hands you back a brand-new one.
Strings support the same slice syntax as lists. Core methods cover the most common operations — searching, transforming, and cleaning.
find returns -1 if the substring isn't found; index raises ValueError. Use in for a boolean check, find for a safe position lookup.
The third argument in s[start:stop:step] controls the stride and direction — a negative step reverses traversal.
Omitting start and stop always means "full range" — direction is set by the sign of step. [::-1] is the idiomatic reverse.
split and join are inverses — split breaks a string into a list, join reassembles it. f-strings are the modern way to embed values inline.
"sep".join(items) — the separator goes on the left, not the right.
Strings are immutable, so every += allocates a brand-new object and copies all previous characters. Concatenating n strings in a loop costs O(n²) — join avoids this by allocating once.
Every += on a string allocates a brand-new object and copies all existing characters into it. With join, Python measures the total length first, allocates once, and fills it — one pass, no copies.
Quick one-liners for the most common string checks.
Four common string checks: palindrome (reversal equality), anagram (character frequency), unique characters (set size), and encoding/decoding between str and bytes.