Indexing, case and whitespace, searching, split/join, f-string formatting and the byte-level bits.
s = "Hello, World"len(s)Number of characters (12).
s[0], s[-1]First and last character; negative indexes count from the end.
s[7:12]Slice from index 7 up to, not including, 12 → 'World'.
s[::-1]Reversed copy; strings are immutable, so every method returns a new one.
"py" * 3Repeat → 'pypypy'.
"Hello, " + "World"Concatenate. For many pieces prefer join or an f-string.
str(42), repr("hi")Any object to text; repr gives the quoted, debug form.
"tab\there\nnew line"\t tab, \n newline, \\ backslash, \" quote.
r"C:\new\dir"Raw string: backslashes are kept literally (use for regex and Windows paths).
s.upper(), s.lower()'HELLO, WORLD', 'hello, world'.
"hello world".title(), "hello".capitalize()'Hello World'; 'Hello' (first letter only).
"Straße".casefold() == "strasse"Aggressive lowercase for case-insensitive comparison.
" pad ".strip()Remove whitespace at both ends; lstrip / rstrip for one side.
"xxhixx".strip("x")Strip a set of characters instead of whitespace.
"7".zfill(3)Left-pad with zeros → '007'.
"hi".center(6, "*"), "hi".ljust(5, "."), "hi".rjust(5)'**hi**', 'hi...', ' hi'.
"World" in sSubstring test → True.
s.find("o"), s.rfind("o")First / last index, or -1 when absent.
s.index("o")Like find but raises ValueError when absent.
s.count("l")Non-overlapping occurrences → 3.
s.startswith("He"), s.endswith(("d", "x"))Prefix / suffix test; a tuple means any of them.
"abc".isalpha(), "123".isdigit(), "a1".isalnum()Only letters / only digits / letters or digits.
" ".isspace(), "Hello World".istitle(), "ABC".isupper()Whitespace only / title case / all caps.
"3.5".isdigit(), "35".isdigit()→ False, True. To test for a number, use try: float(x) except ValueError.
"a,b,c".split(",")→ ['a', 'b', 'c'].
"a b\tc".split()No argument: split on any whitespace run and drop empties.
"a,b,c".split(",", 1)At most one split → ['a', 'b,c']; rsplit works from the right.
"key=value".partition("=")→ ('key', '=', 'value'); always a 3-tuple.
"one\ntwo\n".splitlines()→ ['one', 'two']; handles \n, \r\n and drops the trailing empty.
", ".join(["a", "b", "c"])Join an iterable of strings → 'a, b, c'. Items must already be str.
s.replace("l", "L"), s.replace("l", "L", 1)Replace all, or only the first n occurrences.
"Hello, World".removeprefix("Hello, ").removesuffix("ld")→ 'Wor' (3.9+); no error when the affix is absent.
f"{2 + 2} is {'four'}"Any expression inside the braces.
f"{3.14159:.2f}"Two decimals → '3.14'.
f"{1234567:,}", f"{1234567:_}"Thousands separator → '1,234,567' / '1_234_567'.
f"[{42:>6}] [{42:<6}] [{42:^6}]"Right / left / centre align in width 6.
f"{0.256:.1%}"Percentage → '25.6%'.
f"{255:x} {255:X} {255:b} {255:08b} {255:o}"Hex, HEX, binary, zero-padded binary, octal.
x = 5; f"{x=}"Debug form → 'x=5' (3.8+).
"{} and {name}".format("a", name="b")str.format: positional and named fields.
"%s: %d" % ("count", 3)printf style; still common in logging calls.
ord("A"), chr(65)Character ↔ code point (65).
"é".encode("utf-8")→ b'\xc3\xa9'; bytes is what files and sockets carry.
b"\xc3\xa9".decode("utf-8")Bytes back to str → 'é'.
"abc".translate(str.maketrans("ab", "xy"))Per-character mapping → 'xyc'; pass a 3rd arg to delete chars.
Want the topic explained, not just listed? The Strings lesson walks through it with graded exercises. Preparing for interviews? See the interview prep track.