Strings

17 articles
Interview Preparation Intermediate

9.16 Hands-on Exercises

Log Level Analyzer Build a function that scans a batch of log lines and tallies how many fall into each severity level — an at-a-glance …

Jan 20, 2026 Read more
Interview Preparation Intermediate

9.15 Interview Questions

Conceptual Questions Why are Python strings immutable, and what does that mean for methods like .replace()? What’s the difference …

Jan 20, 2026 Read more
Interview Preparation Intermediate

9.14 Common Mistakes

Assuming a Method Mutates in Place Every string method returns a new string — the original is never changed, since str is immutable (see 9.1 …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.13 Best Practices

Build Large Strings with join(), Not += Accumulating a string with += inside a loop is O(n²); collecting pieces in a list and calling …

Jan 20, 2026 Read more
Interview Preparation Intermediate

9.12 Strings in DevOps and AWS

Almost everything touched in cloud and infrastructure automation is a string: log lines, Amazon Resource Names (ARNs), IAM policy documents, …

Jan 20, 2026 Read more
Interview Preparation Intermediate

9.11 Memory and Performance

Why Immutability Matters Here Immutability makes strings safe to share across functions, threads, and dict/set keys without defensive …

Jan 20, 2026 Read more
Interview Preparation Intermediate

9.9 String Algorithms

flowchart TD SA["String Algorithms"] SA --> CH["Check\npalindrome, anagram"] SA --> TR["Transform\nreverse, compress"] SA --> …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.8 String Functions

These are global built-in functions that accept a string as an argument, rather than methods called on the string object itself (len(s) vs. …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.7 Common String Methods

Every method below returns a new string (or list/tuple) — none modify the original, consistent with 9.1 Introduction to Strings. Case …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.6 String Formatting

Three Ways to Format flowchart TD A["% operator\nlegacy, printf-style"] --> D["Same output"] B[".format()\nPython 2.7+, readable"] --> D …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.5 String Operators

Concatenation (+) Joins two strings end-to-end into a new string — the simplest way to build text from pieces, used constantly for messages, …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.4 String Indexing and Slicing

Indexing and Negative Indexing Every character in a string has a position. Positive indices count from the left starting at 0; negative …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.3 Escape Characters

The core escape sequences (\n, \t, \\, quotes) were introduced in 4.13 Escape Characters. This is the complete reference, including the …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.2 Creating Strings

Single and Double Quotes Single and double quotes are functionally identical — the choice is purely stylistic, except when the text itself …

Jan 20, 2026 Read more
Interview Preparation Beginner

9.1 Introduction to Strings

flowchart TD S["str"] S --> C["Creation\nquotes, raw, unicode"] S --> I["Indexing & Slicing"] S --> F["Formatting\n% .format f-strings"] S …

Jan 20, 2026 Read more
Interview Preparation Beginner

Strings

Concatenation FIRST="Hello" SECOND="World" GREETING="$FIRST $SECOND" # simple concatenation via adjacency …

Jan 20, 2026 Read more