Characters, Indexes, and Slices
Scenario: A log prefix contains a date and service code that must be separated.
New words, in plain English
- String - an ordered sequence of text characters
- Index - a character position starting at zero
- Slice - a selected range written
[start:stop:step]
text[0] gets the first character and text[-1] the last. Slices stop before the stop index. Strings are immutable: operations produce new strings rather than changing the original.
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
stamp = "2026-09-05 API"
print(stamp[:10])
print(stamp[11:])
print(stamp[::-1])
Tip: A missing slice boundary means start or finish; the stop position is never included.
Goal: Practice this idea in the py-string-manipulation challenge at/labs/python. Fix the broken program, run it yourself, then usecheckto prove the real end state.