Going deeper: your syntax reference is the assistant next to you
This lab covered the three things worth reading first in any script AI
hands you: what the names hold, whether the function actually returns,
and which branch of the if chain really fires. You will keep meeting
syntax this lab never mentioned — list comprehensions, try/except,
lambda, decorators. That is expected. You don't need a reference book
on the shelf. You have an AI assistant open already, and it is the best
syntax reference ever built — if you ask it the right way and verify
what it says.
The prompt pattern
When you hit a construct you can't read, paste it into your assistant with this pattern:
Explain this construct three ways: what it does, what beginners
get wrong, and a five-line example I can run.
<paste the code here>
Why these three parts earn their place:
- What it does gives you the plain-language reading — the same "treat it like a labeled note" move you practiced in lesson 1.
- What beginners get wrong is the trap list. You've seen in this lab
that the traps (
=vs==,printvsreturn,0counting as falsy) matter more than the happy path. Asking for them directly gets you the part references usually bury. - A five-line example I can run forces the answer into something checkable. Five lines is small enough to read whole and big enough to show the construct doing real work.
The verification habit
Here is the part that separates a builder from a believer: run the example. Don't trust the explanation.
Assistants explain fluently and are occasionally wrong — you just spent a lesson on the hallucinated return, a bug that reads as correct. The same failure mode applies to explanations about code. An explanation you haven't run is a claim. An example that runs and prints what the explanation predicted is evidence.
So the loop is: paste the construct, get the three-part answer, run the five-line example, and check the output against what the explanation said would happen. If they disagree, say so in the next message — "the example printed X, you said Y" — and make the assistant reconcile it. That one habit converts the assistant from an oracle into a reference you can actually lean on.
Try it now: the editor holds a five-line example of the kind this prompt produces. Predict its output from what you learned in this lesson, then run it and check yourself.
The canonical reference
When you want the ground truth in written form, the official Python tutorial at docs.python.org is the one canonical, vendor-neutral source — maintained by the people who maintain the language. Use it to settle disputes, and use your assistant to get there faster.