Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
Without looking back: what does a list index of 0 retrieve?
Show the answer
The first item. Python starts counting positions at zero.
Clean a copy; keep the original evidence
Clip names arrive as strings: text, even when some characters look like numbers. A method is an operation called on a value using a dot and parentheses. strip() removes outside whitespace, lower() changes letter case, and replace(old, new) replaces matching text.
Each method returns a new string. Chaining works left to right: the next method receives the previous result. A lowercase replacement is case-sensitive, so lower before removing a lowercase draft marker. Internal spaces in a project name are not noise unless your policy says they are.
# Preserve the raw text; clean a separate value.
raw_name = " NIGHT SHIFT draft.MOV "
clean_name = raw_name.strip().lower().replace(" draft", "")
# Compare the new text with the unchanged original.
print(clean_name)
print(raw_name == clean_name)The output is night shift.mov, then False. raw_name still contains its original spaces and capitals. This is a training normalization policy, not permission to rename real files.
Read the chain, change the requested replacement, fill the scaffold, then clean a different raw name yourself. Test a name with no draft marker too.
Predict, explain, then test
These three brief checks are self-reviewed, not a scored quiz. Explain your answer before opening the comparison. Coding checks test the stated data contract on unfamiliar inputs.
Predict the chain
What happens to " Canal Draft.MOV " after strip(), lower(), then replace(" draft", "")?
Compare your answer · self-reviewed
canal.mov. Lowercasing first lets the lowercase marker match. Internal spaces unrelated to the marker remain.
Explain the original
After clean = raw.strip(), has raw itself lost its spaces?
Compare your answer · self-reviewed
No. Strings are immutable and strip returns a new string. Assigning to clean preserves raw; assigning back to raw changes what that variable refers to.
Repair the policy
Would replace(" ", "") preserve a multi-word project name?
Compare your answer · self-reviewed
No. It removes internal spaces too. strip removes only the edges; use it when the policy preserves spaces inside a name.
Choose an exercise to load its prompt.
Loading exercises…
Noted on your route map, with the step you were on. Nothing is lost by parking it — the next review day will bring this idea back, and the flag tells the course where to slow down.
The tutor mounts here when JavaScript is available. The lesson above stays readable without it.