Key Ideas
1What is a String?. A string is a sequence of characters — letters, digits, spaces, symbols, or even emojis — wrapped in quotes. Strings are one of the most used data types in any program...
2Indexing & Slicing. Every character in a string has a position number called an index. Python indexes start at 0 (not 1!). You can also count from the end using negative indexes — -1 is a...
3Essential String Methods. Python strings come with 50+ built-in methods. You call them with dot notation: string.method(). Here are the most important ones you'll use daily.
4f-Strings — Modern String Formatting. An f-string (formatted string literal) is the modern, clean way to embed variables and expressions directly inside a string. Prefix the string with f and put variables...
5Escape Characters. Some characters can't be typed directly inside a string — like a newline, a tab, or a backslash. You use an escape sequence: a backslash \ followed by a special charac...