Free lab Real Python 3. Zero installs. Your code stays in this browser. Open the playground

Break Problems Down Before You Code

12 min 30 XP
Study loop Read Predict Run Tweak Prove Review
Lesson 1 of 5 · View course roadmap
Step 1

Learn the idea

Staring at a blank editor isn't a coding problem — it's a decomposition problem. Professionals never solve "the task"; they solve a chain of tiny steps:

  • What comes in? (a list of numbers)
  • What goes out? (a count, a total, an average)
  • What are the steps between? — each one small enough to be one or two lines

Write the steps as comments first, then turn each comment into code. This "comment skeleton" technique feels almost too simple, and it is exactly how experienced developers start anything unfamiliar. A problem you can list, you can code.

Where you'll use this

Ticket breakdowns, pseudocode in design docs, TODO-comment skeletons — decomposition is the daily bread of professional programming. Interviewers score the way you split the problem before they score your syntax.

Common mistakes

  • Starting to type before you can say the steps out loud — blank-editor paralysis is a planning gap, not a skill gap.
  • Steps that are too big ('process the data') — a good step maps to one or two lines of code.
  • Skipping the 'what comes out?' question and coding toward the wrong output format.

Pro tip

If a step feels hard to code, decompose that step again. Recursion isn't only for functions — it's how you plan.

Step 2

Try it yourself

Blank · autosaved

The lesson example is loaded and ready — press Run, then change something and run it again. Breaking it is part of learning. Want a clean slate? Tap “New blank”.

PYexample.py
+ Enter to run
Output appears here…
Step 3

Pass the challenge +30 XP

Blank · autosaved

Decompose and solve: for nums = [4, 8, 15, 16, 23, 42], print the count of numbers, then the total, then the average — one per line.

Target output
6
108
18.0
PYchallenge.py
Run your code to check it…
Step 4

Check your understanding

1. What's the first question to ask about any programming task?
2. Why write steps as comments before coding?
Last step

Your notes (saved on this device)

Tip: use and to move between lessons, K to search everything.

Your next ten minutes

Write Python that does something useful.

Start free. No install, no card, no passive video marathon.

Start learning free → Explore the path