How to learn programming without copying code
Last updated: 2026-11-23
To learn programming without copying code, read the error message and say what it means before you change anything, predict what the code will do before you run it, rebuild the working version from memory afterward, and ask for the smallest hint only after you have tried. Pasting a finished solution gets the program running, but the studies we read suggest that trying first and getting feedback soon after helps more. The steps below are our own arrangement of those findings, because none of the studies were about learning to code, and we say where we are guessing.
Start learning No account needed
1. Read the error before you do anything else
An error message usually names a kind of problem, a file and a line. Before you search for it or paste it anywhere, write one sentence in your own words: what kind of problem it names, and which line it points to. Then look at that line and the line above it. We did not read a study of this step; it is a habit we suggest because it turns "it is broken" into one specific question you can work on.
Python. "TypeError: can only concatenate str (not int) to str" on line 12 means you joined text and a number; check what the variable on that line holds. JavaScript. "Cannot read properties of undefined" means something you treated as an object has no value yet; find where it should have been set.
2. Predict before you run
Before you run the code, write down what you expect it to print or do, including the values of the variables at the line that worries you. Then run it and compare. A wrong prediction is useful: it points at the line where your picture of the code and the code disagree. Richland and colleagues had students answer questions about a passage before reading it; the students got about 95 percent of those questions wrong in the first experiment, and still remembered more of the passage afterward than students who spent the same time reading it with no questions. That study used reading, not code, so we read it as a reason to guess first, not as proof about programming.
Example. For a loop that adds the numbers 1 to 5 into a total, write what total holds after each pass before you run it. If the program prints something different, the first pass where your numbers split from the output is where to look.
3. Rebuild it from memory
After you have a working solution from a tutorial, a classmate or the documentation, close it and write the function again from a blank file. Get as far as you can, run it, then open the original and mark the lines you could not produce. Roediger and Karpicke had students study a passage and then either reread it or write down what they remembered. Five minutes later the rereaders did better. Two days and a week later the group that had written from memory remembered substantially more, even though the rereaders felt more sure they would remember.
Rebuilding feels worse than reading the solution again, and the research we read says that feeling is not a sign it is failing. Our guide to testing yourself covers the method in more detail. The studies used prose passages, so how well this carries over to writing code is our guess. Rebuild a day later with the marked lines first, and then change the problem a little, for example sum the even numbers instead.
4. Know when to ask for a hint
Ask when you can show three things: the error in your own words, the prediction you made, and one change you tried because of it. If you cannot write those down yet, go back a step. If you can, ask for the smallest piece of help that moves you: which line to look at, the name of the concept, or the first line of the fix. Then close it and write the next step yourself. Hays and colleagues found that after a failed attempt, feedback given right away led to better recall than showing the answer with no attempt. That study used word pairs, so we read it as support for checking soon after you try, not as proof about code.
Kapur and Lee had seventh-grade students work on a hard math problem without help before the teacher explained the method. The students mostly did not solve it, and they still did better on the later test than classmates who were taught first. That does not say how long to struggle with code; we found no tested time limit, so a few honest minutes with your attempt written down is a reasonable start.
What about autocomplete and copied snippets?
Copying a line is not a problem in itself, since most working programmers look things up. The question is whether you can explain each line you pasted and write it again later. A line you can explain after closing the tab is yours. If you cannot, treat it as step 3 material: close it and rebuild it. If your course has rules on outside code or AI tools, follow those; we cannot see them.
For the wider routine for any problem, see how to get unstuck and how to test yourself.
What the sources found, and their limits
Richland, Kornell and Kao, 2009. Five experiments with undergraduates reading a passage about vision. Students asked about key points before reading did better afterward than students given extra reading time, even counting only the questions they had missed. Limits: reading and facts, not code; one passage. Source: The Pretesting Effect, Journal of Experimental Psychology: Applied, 2009, read on 2026-11-15.
Roediger and Karpicke, 2006. Two experiments with college students who studied prose passages, then either restudied them or took one or three free-recall tests with no feedback. On a test after 5 minutes restudying did better. After 2 days and 1 week prior testing gave substantially greater retention. Limits: prose passages in a lab, and we read the abstract record, not the full paper. Source: Europe PMC abstract record, 2006, read on 2026-11-15.
Hays, Kornell and Bjork, 2012. Three experiments on pairs of words such as frog and pond. A failed test followed by immediate feedback produced better recall than just showing the pair. Limits: word pairs only, no problem solving, and short delays. Source: When and Why a Failed Test Potentiates the Effectiveness of Subsequent Study, Journal of Experimental Psychology: Learning, Memory, and Cognition, 2012, read on 2026-11-15.
Kapur and Lee, 2009. Two quasi-experimental studies in Singapore schools on a unit about average speed. Students who worked on complex problems without support before a teacher-led explanation scored higher on the later test than students who got a lecture and practice. Limits: assigned classes, one math unit, and the teacher explained the method afterward, so this is not the same as being stuck alone with no help. Source: Designing for Productive Failure in Mathematical Problem Solving, Proceedings of the Cognitive Science Society, 2009, read on 2026-11-15.
How Professor Turing helps
Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start.
As a personal tutor, it starts from your work. Describe what you were trying to build, paste the error, and say what you think it means. The first reply asks what you already know before it teaches anything. If you send only a fix, it asks how you got there. It's an AI tutor, so check what it tells you against the documentation when the details matter.
You must be 18 or older, and conversations are deleted after 7 days.
FAQ
Is it cheating to look up a solution? That depends on your course rules, which we cannot see. For learning, the studies we read suggest the order matters: attempt first, then check.
How long should I try before I ask for a hint? We found no tested time limit. Ask once you can write down the error, your prediction and one thing you tried.
Does rebuilding from memory work for code? The recall studies we read used reading passages, so we do not know how large the benefit is for code. We suggest it because it shows which lines you could not write yourself.
Start with what you're working on
Paste the error you are looking at, and let the tutor ask the first question.
Start learning No account needed
See also: all study guides