Methods for Real Text

Scenario: Names arrive with extra spaces and inconsistent capitalization.

New words, in plain English

Useful methods include strip, lower, upper, title, replace, startswith, endswith, split, and join. Use in for membership.

Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.

A small, real example

raw = "  api,db,cache  "
services = raw.strip().split(",")
print(" | ".join(services))
Tip: Strings do not change in place, so store or use the returned string.
Goal: Practice this idea in the py-string-manipulation challenge at /labs/python. Fix the broken program, run it yourself, then use check to prove the real end state.