How to Get Unstuck on a Practice Problem Without Peeking
Every programmer gets stuck. Beginners get stuck on loops and syntax errors; experienced developers get stuck on tricky bugs and design problems. The difference is not how often they get stuck but how they get unstuck.

Every programmer gets stuck. Beginners get stuck on loops and syntax errors; experienced developers get stuck on tricky bugs and design problems. The difference is not how often they get stuck but how they get unstuck. When you are practising, the temptation is to peek at the solution after a few minutes of frustration. Sometimes that is fine. But learning to work through being stuck, at least for a while, is one of the most valuable skills you can build.
I coach students for programming contests, where nobody can peek at solutions. Here are the techniques that help them get unstuck on practice problems.
Read the problem again, slowly
A surprising number of "stuck" moments come from misreading the problem. Read it again, slowly, and underline the key requirements: what is the input, what should the output be, what are the limits? Rewrite the problem in your own words. If you cannot explain it simply, you do not understand it yet, and no amount of coding will fix that.
Work through examples by hand
Take the example input and solve it on paper, step by step, without any code. Then try a second example you invent yourself, including edge cases: an empty list, a single item, very large numbers, negative numbers. Solving by hand often reveals the algorithm. If you cannot solve an example by hand, you cannot write code to solve it.
Break the problem into smaller pieces
Large problems are made of small ones. If the task is to find the most common word in a text, break it down: split the text into words, count each word, find the largest count. Solve each piece separately. Write and test a small function for each step before combining them.
This approach is the foundation of all programming, from beginner exercises to large projects, and it underpins the advice in what to learn first when you know nothing about coding.
Print everything
When code runs but gives the wrong answer, add print() statements to show what the program is doing at each step. Print variables inside loops, print the result of each function and print which branch of an if statement runs. Most bugs become obvious once you see the actual values instead of the values you assumed.
Read error messages carefully too. Python's error messages tell you the line number and type of error. A NameError usually means a typo in a variable name; an IndexError means you went past the end of a list.
Explain it to a rubber duck
Programmers have a famous technique called rubber duck debugging: explain your code, line by line, to an inanimate object such as a rubber duck. The act of explaining forces you to slow down and notice assumptions. Many problems are solved halfway through the explanation. A patient friend or club member works even better.
Take a break
When you have been stuck for a long time, walk away. Go for a walk, make a drink or sleep on it. Your brain keeps working on problems in the background, and many solutions appear when you return with fresh eyes. This is not giving up; it is a well-known part of problem solving.
When is it fine to peek?
Some teachers insist students should never look at solutions. I think that is too strict. Being stuck for hours without progress is discouraging and can make people quit.
A better rule is to set a time limit, perhaps 30 to 45 minutes of genuine effort using the techniques above. If you are still stuck, look at a hint, not the full solution. If you need the full solution, read it carefully, close it, and then write the solution yourself from memory. Come back to the same problem a few days later and solve it again without help. That way, peeking becomes part of learning rather than a shortcut around it.
Learn from every stuck moment
After solving a problem, take a minute to reflect. What made it hard? What technique finally helped? Keep a short log of lessons learned. Over time, you will notice patterns: the same mistakes, the same kinds of problems, the same useful tricks. Problems inspired by games make good practice material, as in online game puzzles that secretly teach programming.
A getting-unstuck checklist
- Reread the problem and restate it in your own words.
- Solve examples by hand, including edge cases.
- Break the task into small steps and test each one.
- Print values and read error messages carefully.
- Explain your code out loud.
- Take a break, then try again.
- Use a hint before a full solution, and redo the problem later.
Stuck is where learning happens
The moments when you are stuck are uncomfortable, but they are where real learning happens. With a few techniques and a little patience, you will get unstuck more often and faster, and you will become a better programmer each time. More in our Python and Practice section.
More from the blog
Python and Practice
Python Loops Explained With Things You Already Do
Loops are where many beginners first feel that programming is getting difficult.
Teaching Code
Why Online Game Players Often Make Fast Learning Coders
Coding club organisers and teachers often notice something interesting: students who play a lot of online games frequently pick...
First Steps
How Online Gaming Servers Explain the Basics of Networking
Networking is one of those topics that sounds intimidating to beginners: packets, protocols, latency, servers, clients and...