- Why most people use ChatGPT wrong when learning to code
- The core prompt structure that teaches you something
- A worked example: learning to build a simple web form
- Prompts for specific learning situations
- Picking where you write the code
- The contrarian bit nobody says out loud
- Prompts for learning adjacent skills
- A realistic timeline, not a fantasy one
- Frequently asked questions
The short version: ChatGPT is a brilliant coding tutor only if you stop asking it to write code for you and start asking it to explain, quiz and correct you. The prompts below are built to slow the process down on purpose, because learning to code by copying finished answers is how you end up with zero skills and a folder full of scripts you don't understand.
Why most people use ChatGPT wrong when learning to code
I'll say the uncomfortable bit first because nobody else seems to. If you ask ChatGPT "write me a Python script that sorts a list of customer names", it will do it in two seconds, and you will have learned nothing. You'll have a working script and the same skill level you had before you opened the chat. That's not a learning tool, that's a vending machine.
The entire trick to using ChatGPT for learning to code is changing what you ask it for. You're not asking it to produce code. You're asking it to produce understanding, with code as the by-product. That means your prompts need to include instructions like "don't give me the full answer", "ask me questions first" and "make me write the next line myself".
This matters more than people admit because AI code generators are now good enough to write entire working apps from a single prompt. Tools exist specifically for that, and if you want to compare them there's a free AI code generator comparison worth reading. But generating code and learning to code are two completely different goals, and conflating them is the single biggest mistake I see people make.
The core prompt structure that teaches you something
Every good learning prompt has three parts: the goal, the constraint, and the check. Here's the template:
- Goal: what you're trying to learn (a concept, not a finished project)
- Constraint: how ChatGPT should behave (don't give the full solution, ask me one question at a time, explain in plain English first)
- Check: how it confirms you've understood (quiz me, ask me to explain it back, give me a broken version to fix)
So instead of "explain Python loops", try: "I'm learning Python and I want to understand for loops. Explain the concept in plain English with a real-world comparison, then give me a small broken example with a bug in it and ask me to find and fix the bug before you tell me the answer."
A worked example: learning to build a simple web form
Say you run a small online shop and you want to learn enough HTML, CSS and JavaScript to build and tweak your own contact form instead of paying a developer every time something needs changing. Here's how a sensible prompt sequence would go, step by step.
- Step 1: "I want to learn to build a simple contact form with HTML, CSS and JavaScript validation. Break this into 5 stages I should learn in order, from easiest to hardest, and tell me what I should be able to do by the end of each stage."
- Step 2: "For stage 1, explain HTML form elements. Don't write the full form for me. Give me the structure of one input field as an example, then ask me to write the rest myself and paste it back to you for feedback."
- Step 3: Paste your attempt back and ask: "Here's my attempt. Don't fix it for me, just tell me what's wrong and why, in plain English, and give me one hint per mistake."
- Step 4: Once the HTML works, ask: "Now explain basic CSS for styling a form, show me one property as an example, and quiz me on the rest before giving answers."
- Step 5: For the JavaScript validation stage: "Explain how to check if an email field is empty using JavaScript. Walk me through the logic in words first, no code, then let me try writing it before you check it."
That's five prompts and roughly 45 minutes of back and forth, and by the end you've written every line yourself with ChatGPT acting as a patient second pair of eyes rather than a code factory. Compare that to one prompt that spits out a finished form in four seconds. You'll forget the second one by lunchtime.
Prompts for specific learning situations
When you're stuck on an error message
Don't paste the error and say "fix it". Say: "I got this error message [paste it]. Before you tell me the fix, explain what this error means in plain English and what's generally the most common cause of it." This builds a mental model of errors instead of a habit of pasting and praying.
When you want to understand someone else's code
"Here's a piece of code I didn't write [paste it]. Go through it line by line and explain what each part does, then ask me three questions to check I've understood it before moving to the next section." This is one of the best uses of ChatGPT for coding, because reading code is a skill nobody teaches and most tutorials skip it entirely.
When you want spaced repetition instead of one-off explanations
"I learned about Python dictionaries yesterday. Give me three small exercises today that use dictionaries, increasing slightly in difficulty, and don't show me the solution until I've attempted each one." Ask for this again in three days with a harder set. This is closer to how memory works than reading one long explanation once.
When you want to practise interview-style coding
"Give me a coding problem similar to what's asked in junior developer interviews, at an easy level. Don't give hints unless I ask. After I submit my solution, review it the way an interviewer would, including code style, not just whether it works."
Picking where you write the code
Prompts are only half the job. You need somewhere to type and run the code, because reading explanations in a chat window without typing anything yourself is close to useless. If you haven't settled on an editor, it's worth looking at a real comparison of code editors rather than guessing, because the right one for a beginner (something with built-in error highlighting and a simple interface) is not the same as what a senior developer wants. VS Code is the usual free starting point and it pairs well with ChatGPT open in a second window, so you can copy small snippets back and forth without losing your place.
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
The contrarian bit nobody says out loud
Here's what most "learn to code with ChatGPT" articles won't tell you plainly: AI is making the early stages of learning to code both easier and more dangerous at the same time. Easier because you've got an infinitely patient tutor available at 11pm on a Tuesday. More dangerous because the temptation to let it do the thinking is constant and it never gets tired of doing it for you. Every single session you let it write the whole thing, you're trading long-term skill for short-term speed, and that trade compounds. Six months of that and you'll have shipped things that work but you won't be able to debug a single one of them without opening ChatGPT again. That's not learning to code. That's outsourcing it to a tool you don't control the output of.
The fix isn't complicated, it's just uncomfortable. Use constraint language in nearly every prompt. "Don't give me the answer yet." "Ask me first." "Let me try before you correct me." It feels slower. It is slower. That's the point.
Prompts for learning adjacent skills
Coding rarely exists on its own, and some of the most useful ChatGPT prompting skill transfers directly. If you're automating spreadsheets rather than building apps, the logic is near identical to coding and there's a dedicated guide to ChatGPT prompts for VBA macros in Excel, Word and Outlook worth reading alongside this one. Likewise, if part of your reason for learning to code is to work with data, it's worth knowing ChatGPT can sit inside Excel itself, covered in this piece on installing the ChatGPT add-in for Excel. And if the maths behind an algorithm is what's tripping you up rather than the syntax, there's a separate set of ChatGPT prompts for maths that show the working rather than just the final number, which is the exact same principle applied to a different subject.
While you're building the habit of working inside ChatGPT constantly, it's worth a few minutes learning the keyboard shortcuts worth knowing, because switching between browser tabs and your editor a hundred times a day adds up to real wasted time over a few weeks of learning.
A realistic timeline, not a fantasy one
If you're starting from nothing and using prompts like the ones above for roughly an hour a day, four or five days a week, a reasonable expectation is: basic syntax and simple scripts within about 3 to 4 weeks, small working projects like the contact form example within 8 to 10 weeks, and comfort reading and modifying other people's code somewhere around the 4 to 6 month mark. These numbers are not magic, they're just what consistent practice at that pace tends to produce, and they'll move faster or slower depending on how much time you put in versus how much you let ChatGPT do for you along the way.
Frequently asked questions
Can ChatGPT teach you to code from scratch?
Yes, but only if you prompt it to explain and quiz rather than to just hand you finished code, because the finished code teaches you nothing and the explanation does.
What's the best first ChatGPT prompt for a complete beginner?
Something like "I've never coded before, I want to learn Python, break it into stages for me and start by explaining variables in plain English with one example, then ask me to write my own before showing more." Starting broad and stage-based stops you drowning in random tutorials.
Should I copy and paste code ChatGPT gives me straight into my project?
Not if you're trying to learn. Paste it back and ask it to explain each line first, then retype it yourself from memory where you can, since typing it yourself is what builds the muscle memory and understanding.
Is it better to use ChatGPT or a dedicated coding course?
They work best together. A structured course gives you the order to learn things in, and ChatGPT gives you unlimited patient practice and explanation on whichever bit of that course you're stuck on at 11pm when there's no tutor around.
Run a business, a brand or a blog? I feature tools, products and expert guest posts for an audience of 15,000. See how it works