The fastest way to learn programming is to write code from memory as early as possible. Watch or read one short lesson, close it, rebuild the example in a blank file, change it, then use the idea in a tiny program of your own. Following along with a tutorial feels like progress, but you only find out what you know when the tutorial is gone.
That gap between "I understood the video" and "I can't start a blank file" is what people call tutorial hell. It's the same gap learning scientists see between rereading and self-testing: material you've just seen feels known because it's familiar, not because you can produce it. This guide shows how to learn programming with a loop that builds recall from day one, plus tracing drills, spaced review of concepts, and a four-week plan.
Why do tutorials feel productive but not stick?
When you follow a tutorial, the instructor makes every decision: what to build, which function to call, what to name it, what to do when it breaks. You type. Your brain never has to retrieve anything, so the next day you recognize the code but can't produce it.
This is the same effect that shows up in memory research. In a classic experiment, students who reread a passage did slightly better on a test five minutes later, but students who practiced recalling it remembered more two days and a week later. Rereading, or rewatching, makes material fluent in the moment. Retrieval makes it last.
Al Sweigart, author of several popular Python books, makes a related point about the standard advice for escaping tutorial hell. "Work on your own projects" backfires when beginners pick projects far too big for their skills. What works is smaller and slower: memorize the basic syntax, retype small programs from scratch, and grow the projects gradually.
How to learn programming faster: the build-retrieve loop
Use this loop for every new concept, from for loops to API calls to recursion.
| Step | What you do | Time |
|---|---|---|
| 1. Learn one thing | Watch or read a single short lesson on one concept | 10–20 min |
| 2. Predict | Before running the example, write down what you think it will output | 2 min |
| 3. Rebuild | Close the lesson. Recreate the example in a blank file. Check only when stuck | 10–20 min |
| 4. Change it | Add a feature, break it on purpose, read the error, fix it | 10–20 min |
| 5. Use it | Apply the concept in a tiny program of your own | 20–40 min |
The predict-then-run step has evidence behind it in programming classes. PRIMM (Predict, Run, Investigate, Modify, Make) is a structured approach that starts with students predicting what code does before running it. In a study of 493 students aged 11–14 across 13 schools, classes taught with PRIMM for 8–12 weeks did better on a post-test than a comparison group.
Step 3 is the one people skip because it's uncomfortable. Do it anyway. The moments where you get stuck and have to think are the moments you're learning; peeking at the solution after ten seconds turns it back into copying.
Trace code by hand before you run it
Tracing means stepping through code line by line and tracking what each variable holds. It sounds old-fashioned, but it's the foundation for everything else. Studies of first-year programming students found that those who can't trace code usually can't explain what it does either, and those who write code well have usually learned to do both.
Try it. What does this print?
total = 0
for n in [4, 7, 2]:
if n > 3:
total += n
print(total)
Write a trace table before you run it:
| Step | n | n > 3? | total |
|---|---|---|---|
| Start | – | – | 0 |
| 1 | 4 | yes | 4 |
| 2 | 7 | yes | 11 |
| 3 | 2 | no | 11 |
It prints 11. Five minutes of tracing like this every day trains you to read code the way an interpreter does, which makes debugging much faster. When you're reading someone else's code, trace one function before you change it.
Rewrite code from memory, on a schedule
Rebuilding an example once is good. Rebuilding it again days later, when it's half-forgotten, is better, because spaced retrieval is what makes skills last. Here's how one exercise travels through a week:
- Day 1: follow a lesson that counts word frequencies in a sentence. Rebuild it from a blank file.
- Day 2: rebuild it again without looking. Note where you got stuck.
- Day 4: rebuild it with a twist: ignore punctuation, or return the three most common words.
- Day 7: use the same pattern somewhere new, like counting log-file errors by type.
def count_words(text):
counts = {}
for word in text.lower().split():
counts[word] = counts.get(word, 0) + 1
return counts
print(count_words("the cat saw the dog"))
# {'the': 2, 'cat': 1, 'saw': 1, 'dog': 1}
The pattern inside it (loop over items, build up a dictionary) shows up constantly in real programs. Rewriting it from memory four times in a week is what makes it yours. If you keep forgetting specific syntax along the way, our guide on how to remember coding syntax covers which details to memorize and which to look up.
Review concepts with spaced questions
Syntax is the small stuff. Concepts are the decisions: which data structure, why this approach, what happens under the hood. When researchers rated ten common study techniques in 2013, practice testing and spacing were the only two to earn a "high utility" rating, and a concept deck combines both. Keep a short deck of concept questions and review them on a spaced repetition schedule:
- When would you use a dictionary instead of a list?
- What's the difference between
==andisin Python? - Why does a recursive function need a base case, and what happens without one?
- What does
git mergedo differently fromgit rebase? - What is the time cost of checking
x in my_listversusx in my_set?
Answer out loud or in writing before you check. For the "why" questions, explain it as if to a classmate. Explaining out loud is the idea behind rubber duck debugging, and our self-explanation guide shows why it works for learning, not just for finding bugs.
Pick projects you can finish
Projects are where everything comes together, but size matters more than ambition. Move up one rung at a time:
| Level | Example projects | Target size |
|---|---|---|
| Tiny | Tip calculator, number-guessing game, word counter | An evening |
| Small | To-do list saved to a file, quiz from a CSV of questions, weather lookup from a free API | A weekend |
| Medium | Personal budget tracker with charts, simple web app with login, Discord or Telegram bot | Two to four weeks |
A good project uses things you've learned plus one or two you haven't. If you need a tutorial for every step, it's too big; shrink it. When it's done, rebuild the core from memory a week later. Repeating a specific skill with feedback until it's automatic is the heart of deliberate practice.
Use AI and search without skipping the learning
Looking things up is normal; professionals do it all day. The question is when.
- Try first. Give a problem a real attempt, 15–20 minutes, before searching or asking an AI assistant.
- Ask for hints, not solutions. "What concept should I look at?" teaches more than "write this for me."
- Explain anything you paste. If you can't explain each line, you haven't learned it yet. Trace it, then rebuild it from memory the next day.
- Keep a bug log. Write down each error that took you more than ten minutes, what caused it and the fix. Review it weekly. Repeated bugs become flashcards.
A four-week plan for learning to code
This assumes about six hours a week on one language. The balance matters more than the total.
How a six-hour learning week could split
A balanced week for a beginner, weighted toward writing code
Illustrative plan, not measured data.
View data
| Activity | Hours per week |
|---|---|
| Your own small project | 2.5 h |
| Rebuilding examples from memory | 1.5 h |
| New lessons or reading | 1 h |
| Tracing, concept review and bug log | 1 h |
| Week | Focus | By the end you can… |
|---|---|---|
| 1 | Variables, conditionals, loops. Daily trace drills. Build a number-guessing game. | Write a loop with a condition from a blank file |
| 2 | Lists and dictionaries. Rebuild last week's examples on days 2, 4 and 7. Build a word counter. | Choose between a list and a dictionary and explain why |
| 3 | Functions and files. Start a concept deck. Build a to-do list that saves to a file. | Split a program into functions you can test one at a time |
| 4 | A small project using everything so far, such as a quiz app that reads questions from a CSV. Rebuild week 1–3 exercises from memory. | Start a small program on your own without a tutorial |
From there, keep the same loop with bigger concepts: classes, APIs, a web framework, a database. The habit you're building is starting from a blank file. Once that stops feeling scary, you're out of tutorial hell. For the general principles behind this plan, see what active recall is and the best study techniques for students.
Frequently asked questions
What is the fastest way to learn programming?
Spend most of your time writing code rather than watching it. Learn one small concept, rebuild the example from memory in a blank file, change it, and use it in a tiny program of your own. Revisit old exercises after a few days. This build-retrieve loop feels slower than bingeing tutorials, but you keep far more of what you learn.
How do I get out of tutorial hell?
Stop finishing tutorials and start rebuilding them. After each lesson, close it and recreate the code from a blank file, then add one feature the tutorial didn't cover. Choose projects small enough to finish in an evening or a weekend, and only look things up after a real attempt. Progress means you can start without a tutorial, not that you finished another course.
Is it OK to look things up while coding?
Yes. Professional developers search documentation constantly. The difference while learning is timing: try first for 15–20 minutes, then look up the specific thing you're missing. Afterwards, rebuild that part from memory so you need to look it up less next time. Memorize the core syntax you use daily and look up the rest.
Should I use flashcards to learn programming?
For some things, yes: core syntax, concept questions, and errors you keep repeating. Flashcards can't teach you to build programs, so keep them to about 10–15 minutes a day and spend the rest of your time writing code. Cards that ask you to write a snippet or predict an output are more useful than definition cards.
How many hours a day should I practice coding?
Consistency beats volume. One focused hour a day, mostly spent writing and rebuilding code, usually beats a single long weekend session, because spaced practice helps memory. If you can do more, add project time rather than more tutorials. Stop when you're too tired to debug carefully; tired practice builds bad habits.
Should I learn a programming language by reading or by doing?
Mostly by doing. Read or watch just enough to understand one concept, then switch to writing code. In the plan above, only about one hour in six goes to new lessons; the rest is writing, rebuilding and reviewing. Reading other people's code is valuable too, but trace it line by line instead of skimming.
Sources and further reading
Start with the primary research and official guidance below. Links open in a new tab so you can compare the evidence with the article.
- Read source
Test-enhanced learning: Taking memory tests improves long-term retention
Roediger & Karpicke, Psychological Science, 2006
- Read source
Further evidence of a relationship between explaining, tracing and writing skills in introductory programming
Lister, Fidge & Teague, ACM SIGCSE Bulletin, 2009
- Read source
Teaching computer programming with PRIMM: a sociocultural perspective
Sentance, Waite & Kallia, Computer Science Education, 2019
- Read source
Two Pieces of Bad Advice for Escaping Tutorial Hell
Al Sweigart, Invent with Python, 2026
- Read source
Improving students' learning with effective learning techniques
Dunlosky et al., Psychological Science in the Public Interest, 2013
