Python Never Guesses What You Meant

No guessing, no auto-repeating, no picking things up by walking over them — only what's written.

  • Lesson 2 of 4
  • Free
  • Ages 10+
  • 3 hands-on levels
Try this lesson interactivelyReal Python, running in your browser.

The dragon explains

Nothing happens that you didn't write

  1. The dragon: Here's what surprises people most: I never fill in a gap for you.

  2. The dragon: If a step is missing, NOTHING happens for it. No line says 'down', so I never go down — I just bonk into the rock.

    example.pyPython 3
    move_right()move_right()
  3. The dragon: Repeating works the same way. One line runs once — one move_right() is one step, even with the gold far away.

    example.pyPython 3
    move_right()
  4. The dragon: And walking over something never picks it up. Watch: I walk right over the gem and keep nothing.

    example.pyPython 3
    move_right()move_right()
  5. The dragon: Only grab() picks things up — and only what I'm standing on.

    example.pyPython 3
    move_right()grab()
  6. The dragon: This will matter a lot once loops arrive. For now, remember: only what's written, happens.

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 2

    I walk onto the gem and then off it again. How many gems am I carrying?

    question.pyPython 3
    move_right()move_right()
    • None — no line grabbed itCorrect
    • One — I walked right over it

    Why: None. There's no grab() in the code, so nothing gets picked up — however close I walk.

  2. Question 2 of 2

    move_right() is written ONCE. How many tiles do I move?

    question.pyPython 3
    move_right()
    • OneCorrect
    • As many as it takes to reach the gold

    Why: One. A single line runs once — one step, no more, no less.

In the game

What you'll practice

Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.

  1. 1

    GuidedYour first try

    The dragon doesn't fill in gaps. This code is missing one step — there's a rock in the way, and nothing tells the dragon to go around it. Run it to see where it gets stuck, then add the missing line.

  2. +2

    PracticeTwo more, on your own

Try it yourself — in real Python.

This lesson is part of a free topic: every lesson in it is free, and no card is needed.

Start this lesson for real

Stuck three times? The game offers the answer — unasked.