Sub topic 4
Try First, Then Ask: An Attempt-First Workflow
This chapter assumes you can write functions, conditionals and loops in Python, run a script and a simple test, and have used a chat-based AI assistant. It builds on the earlier chapters on how skill develops and on the roles an AI can play.
Why the order matters
When you meet a problem, the effortful part is retrieving what you know, trying an approach, and noticing where it fails. That effort is what builds skill. If you ask the AI first, it does that work for you, and you only read the result. Reading a solution feels like understanding, but it often isn't.
An attempt-first workflow puts your own attempt before any AI help. The AI then acts as a tutor and reviewer, and the full solution comes last, if at all.
The workflow
The steps in words:
- Predict. Before writing code, state what you expect. Write down the approach in a sentence or two, or the output you expect from a snippet.
- Attempt. Write your best version, even if it is incomplete. A broken attempt shows you and the AI where your understanding stops.
- Struggle for a fixed time. Pick a limit, such as 15 minutes, and use it to debug. Stopping at a time limit keeps the struggle productive and stops it turning into frustration.
- Ask for the smallest help. Ask for a question first, then a hint, and only then more.
- Review. Once your code works, ask the AI to critique it.
- Rewrite. If you saw a full solution, close it and write it again from memory.
Predict, then run
Prediction turns running code into a test of your own mental model. Write your guess down before you run this:
def count_vowels(text):
return sum(1 for ch in text.lower() if ch in "aeiou")
# Predict the output before you run this line.
print(count_vowels("Learning with AI"))The expected result is 6: the vowels are e, a, i, i, a and I (counted after lowercasing). If your guess differs, don't just accept the output. Count the letters by hand and find which assumption was wrong. That gap between prediction and result is where the learning happens.
Asking for help in the right order
Escalate help in steps, and stop as soon as you can continue on your own.
| Level | What you ask for | What you keep |
|---|---|---|
| 1 | A question that points at the problem | All the reasoning |
| 2 | A hint about where to look | Most of the reasoning |
| 3 | An explanation of the concept | The fix |
| 4 | A worked solution | Only the rewrite from memory |
A prompt that sets this up:
I am learning Python. I tried to write a function that returns the median of a list, and my code is below.
<paste your code and the error or wrong output>
Do not give me the full solution. First, ask me one question that helps me find the problem. If I am still stuck, give a hint. After I fix it, review my code and tell me what to improve.Include your code and the actual error or wrong output. Without them, the AI has to guess your problem and will often fall back on a generic full answer.
Common mistakes
- Attempting only in your head. "I'd probably use a loop" is not an attempt. Write the code.
- Asking at the first error. Read the error message and form one hypothesis before you ask.
- Skipping the rewrite. Seeing a solution and copying it teaches little. Rewriting it from memory shows what you retained.
- Accepting the first level of help you are offered. If the AI gives a full answer anyway, treat it as level 4 and do the rewrite step.
Exercise
Exercise
You are stuck on a function that should return the median of a list, and you have spent 20 minutes on it. Which request follows the attempt-first workflow: "Write median() for me", or "Here is my code and its wrong output for [4, 1, 3, 2]. Ask me one question that helps me find the bug"? Explain why, and say what you do if you still cannot continue afterward.
Show answer
The second request. It includes your attempt and evidence of the failure, and it asks for the smallest help (a question), so you still do the reasoning. If you are still stuck after the question, ask for a hint, then an explanation. If you eventually see a full solution, close it and rewrite it from memory before moving on.