When you first learn Python, you can spend a long time stuck on one level simply because you do not know how to begin writing the code. Instead of memorizing a finished answer, first check the objective and the current situation, then compare only the parts you need with the example solution. This way, you can keep the problem-solving process intact.

Codedash's Python Mine is a game-based learning environment where you move a miner, remove rocks, and mine iron, gold, and blue gems. Across three short chapters, you practice function calls, loops, conditionals, function definitions, and responding to randomized states in sequence.

Python Mine banner showing a ladder, a miner, and mine tunnels
Python MineUse code to move through the tunnels, inspect nearby resources, and mine only the ore you need.

All 15 Levels in Chapters 1-3 at a Glance

LevelMissionCore concept
1. Mine MovementMove to the ladder on the rightFunction calls and order
2. Angled TunnelFollow the path that bends downwardMoving in multiple directions
3. ZigzagMove down the steps while avoiding rocksMovement order and repetition
4. U-TurnDetour around the blocking rocksUpward movement and repetition
5. SpiralPass through the spiral tunnelSection-by-section for loops
6. Soft RockBreak rocks and move forwardclear()
7. Iron MiningCollect 5 Ironmine() and ore HP
8. Gold MiningMine gold deep undergroundPathfinding and mining
9. Two-Row PatrolCollect 5 Iron across two rowslook() and functions
10. Deep GoldCollect 2 Gold and reach the ladderCombined conditions and detours
11. Two ChancesMine only twice, collect 2 Gold, and reach the ladderif and action limits
12. Dark Mining 1Mine the randomized GoldLarge, collect 3 Gold, and reach the ladderlook_hp()
13. Dark Mining 2Collect 2 Iron and 2 Gold, then reach the ladderThe or condition
14. Limited ActionsCollect 3 Iron within the action limits and reach the ladderif/elif
15. Pressure Plate - Blue GemFind gold and a blue gem, then reach the exitdef and randomized searches
CURRENT LIVE LEVELS

This guide covers the 15 levels in Chapters 1-3 that are currently playable in the game. Each solution is one example that can clear the level; other code that achieves the same objective can also be correct.

TRY FIRST, CHECK LATER

Read each level's objective and suggested approach, then try it yourself first. If you get stuck, open View Level Example Solution to see the complete code and its key behavior.

Functions and Python Syntax to Know Before Mining

01 / MOVE

Move in a direction

Use a Dir value to choose the direction the miner moves.

move(Dir.Right)
02 / CLEAR

Remove rocks

Remove soft rocks and unwanted ore on top of them. This does not work on HardRock.

clear(Dir.Right)
03 / MINE

Mine ore

Mine as many times as the ore's HP to add the resource to your inventory.

mine(Dir.Right)
04 / LOOK

Inspect the resource ahead

Read the resource type before moving and choose an action.

look(Dir.Right)
05 / BRANCH

if/elif/else

Perform a different action for each result, such as iron, gold, or rock.

if target == Res.Gold:
    mine()
06 / LOOP

for and while

Repeat an action a set number of times or until you reach the ladder.

while not is_downstairs():
    move(Dir.Right)

move(), clear(), mine(), and look() are not Python built-in functions. They are game-specific functions provided by Python Mine. In contrast, for, while, if, def, lists, and indentation are real Python syntax.

DIRECTION RULE

You must pass a direction to move() and look(). If you omit it, mine() and clear() act on the tile to the right, while look_hp() inspects that tile.

Chapter 1: Following the Mine Paths

The five levels in Chapter 1 teach movement functions and execution order before you begin mining ore. You start by moving right and down. In the last level, you write simple loops for all four directions in sequence to pass through a spiral path.

Start Python Mine Chapter 1
01
CHAPTER 1 · STAGE 01

Mine Movement: Move Six Spaces Right

Objective: Move from the starting point to the downstairs ladder on the right.

Target coordinate (8, 3) move(Dir.Right) Function call · for

In the first level, each call to move(Dir.Right) moves the miner one space to the right. You can write the same command on six lines, but a for loop that repeats a fixed number of times makes the number of moves clearer.

Level 1 Mine Movement game screen with a straight tunnel to the right and the target ladder
Level 1 Mine Movement game screenYou can see the straight tunnel extending to the miner's right and the downstairs ladder at its end.
View Level 1 Example Solution
for _ in range(6):
    move(Dir.Right)

range(6) repeats six times, moving the miner exactly from the starting position to the target ladder.

02
CHAPTER 1 · STAGE 02

Angled Tunnel: Combine Right and Downward Movement

Objective: Follow the tunnel as it bends downward and reach the ladder.

Target coordinate (6, 5) Right + Down Sequential execution

The route goes two spaces right, two spaces down, and then two spaces right again. Even with the correct number of moves, changing the order of the directions will send the miner into a rock, so check the top-to-bottom execution order as well.

Level 2 Angled Tunnel game screen showing a tunnel that bends downward
Level 2 Angled Tunnel game screenThe route moves right, descends, and then heads right again toward the ladder.
View Level 2 Example Solution
for _ in range(2):
    move(Dir.Right)

for _ in range(2):
    move(Dir.Down)

for _ in range(2):
    move(Dir.Right)

Dividing the identical two-space movements into three sections makes each bend and direction easy to check.

03
CHAPTER 1 · STAGE 03

Zigzag: Write the Movement Order Section by Section

Objective: Avoid the rocks, descend in a stair-step zigzag, and reach the ladder.

Target coordinate (7, 5) Right + Down Simple for loops

Trace the path visually and write the moves in this order: two spaces right, one down, one right, one down, and two right. Only the sections that move two consecutive spaces in the same direction need a for loop.

Level 3 Zigzag game screen with a stair-shaped mine tunnel
Level 3 Zigzag game screenThis stair-shaped tunnel between the rocks requires alternating between rightward and downward movement.
View Level 3 Example Solution
for _ in range(2):
    move(Dir.Right)

move(Dir.Down)
move(Dir.Right)
move(Dir.Down)

for _ in range(2):
    move(Dir.Right)

Write each direction change from top to bottom and loop only the two consecutive moves to the right.

04
CHAPTER 1 · STAGE 04

U-Turn: Detour Down and Then Climb Back Up

Objective: Take a wide detour below the blocking rocks and reach the ladder above.

Target coordinate (6, 3) Down + Right + Up Dir.Left unavailable

The directions you can actually use in this level are down, right, and up. First descend three spaces, move four spaces right, and then climb three spaces back up.

Caution: The on-screen hint may mention moving left, but Dir.Left is not available in this level.

Level 4 U-Turn game screen with a lower detour and a ladder above
Level 4 U-Turn game screenThis U-shaped route descends below the central rock wall and climbs back up on the right.
View Level 4 Example Solution
for _ in range(3):
    move(Dir.Down)

for _ in range(4):
    move(Dir.Right)

for _ in range(3):
    move(Dir.Up)

Because the miner descends and climbs the same number of spaces, the final ladder is at the same height as the starting point.

05
CHAPTER 1 · STAGE 05

Spiral: Use Directional Loops to Follow a Spiral Path

Objective: Follow the rock walls in a spiral and reach the inner ladder.

Target coordinate (6, 5) Four directions One for loop per direction

The route is six spaces right, four down, six left, two up, and four right. Writing a separate for loop for each direction lets you compare the spiral route on the screen directly with the code from top to bottom.

Level 5 Spiral game screen with a spiral mine tunnel
Level 5 Spiral game screenThe spiral tunnel winds in several directions from the outside to the inner ladder.
View Level 5 Example Solution
for _ in range(6):
    move(Dir.Right)

for _ in range(4):
    move(Dir.Down)

for _ in range(6):
    move(Dir.Left)

for _ in range(2):
    move(Dir.Up)

for _ in range(4):
    move(Dir.Right)

Starting a new for loop at each direction change preserves the spiral movement order exactly.

Chapter 2: Removing Rocks and Mining Ore

In Chapter 2, you remove soft rocks with clear() and collect ore with mine(). In the later levels, you use look() to inspect the resource ahead and distinguish ore you need from rocks you should remove.

Start Python Mine Chapter 2
06
CHAPTER 2 · STAGE 06

Soft Rock: Turn Cleared Spaces into a Path

Objective: Break the three soft rocks blocking the way and move to the ladder on the right.

Target coordinate (6, 3) clear() Clear, then move

When no direction is given, clear() removes the soft rock to the right. You can move into that space only after removing the rock, so repeat the clear → move sequence three times, then move once more onto the final ladder space.

Level 6 Soft Rock game screen with soft rocks blocking the tunnel to the right
Level 6 Soft Rock game screenYou must remove the three orange soft-rock spaces in order to reach the ladder on the right.
View Level 6 Example Solution
for _ in range(3):
    clear()
    move(Dir.Right)

move(Dir.Right)

The final space contains a ladder rather than a rock, so move there without calling clear().

07
CHAPTER 2 · STAGE 07

Iron Mining: Mine According to Ore Size

Objective: Mine the iron ore in the tunnel and collect 5 Iron.

At least 5 Iron mine() Small once · Medium twice

Small iron ore gives you 1 Iron after one mining action. The final medium iron ore must be mined twice, and once fully mined it adds 2 Iron to your inventory. Remove the empty soft rocks between the ores with clear().

Level 7 Iron Mining game screen with small and medium iron ore in the tunnel
Level 7 Iron Mining game screenYou can see the size difference between the small iron ores in the straight tunnel and the final medium iron ore.
View Level 7 Example Solution
mine()
move(Dir.Right)

clear()
move(Dir.Right)

mine()
move(Dir.Right)

clear()
move(Dir.Right)

mine()
move(Dir.Right)

mine()
mine()

The final two mine() calls completely mine the medium iron ore, which has 2 HP.

08
CHAPTER 2 · STAGE 08

Gold Mining: Reach the Gold in the Deep Tunnel

Objective: Move into the deep lower tunnel and mine 1 Gold.

At least 1 Gold Pathfinding Cannot move onto HardRock

The gold ore sits on hard rock, so you cannot move directly onto its space. Move to the space immediately left of the gold, then call mine() toward the right. The iron ore blocking the tunnel is not part of the collection objective, so you can remove it with clear().

Level 8 Gold Mining game screen with gold ore on hard rock in the lower tunnel
Level 8 Gold Mining game screenThe gold ore at the end of the lower tunnel sits on hard rock, so it must be mined from the space to its left.
View Level 8 Example Solution
move(Dir.Right)
move(Dir.Down)

for _ in range(2):
    move(Dir.Right)

clear()
move(Dir.Right)
mine()

At the final position, mine the gold ore to the right. You cannot remove or step onto the hard rock beneath the gold.

09
CHAPTER 2 · STAGE 09

Two-Row Patrol: Inspect Resources and Mine Only Iron

Objective: Travel back and forth across the upper and lower tunnels and collect 5 Iron.

At least 5 Iron look(direction) def advance()

Use look(direction) to inspect the resource in the next space. If it is iron, mine it with mine(direction). If it is coal or soft rock rather than iron, remove it with clear(direction). Medium iron ore still appears as Res.Iron after the first mining action, so you must mine it once more.

Level 9 Two-Row Patrol game screen with iron ore and coal mixed across two tunnel rows
Level 9 Two-Row Patrol game screenIron ore and coal are mixed across the upper and lower rows, so you must inspect each resource while traveling back and forth.
View Level 9 Example Solution
def advance(direction):
    if look(direction) == Res.Iron:
        mine(direction)
        if look(direction) == Res.Iron:
            mine(direction)
    else:
        clear(direction)

    move(direction)


for _ in range(6):
    advance(Dir.Right)

move(Dir.Down)

for _ in range(6):
    advance(Dir.Left)

The advance() function groups the shared inspect, act, and move sequence so it can be reused for both the rightward and leftward passes.

10
CHAPTER 2 · STAGE 10

Deep Gold: Mine the Gold and Detour to the Exit

Objective: Collect 2 Gold and reach the ladder in the upper right.

At least 2 Gold Target coordinate (8, 3) Meet both conditions

You must mine the medium gold ore twice to receive 2 Gold. After mining it, descend into the same space and circle around through the upper detour. This level does not clear if you complete only one condition: you must both collect the gold and reach the ladder.

Level 10 Deep Gold game screen with gold ore below and the target ladder in the upper right
Level 10 Deep Gold game screenAfter mining the medium gold ore below, you must return through the upper tunnel and move to the ladder on the right.
View Level 10 Example Solution
def advance(direction):
    while look(direction) == Res.Gold:
        mine(direction)

    if look(direction) == Res.SoftRock:
        clear(direction)

    move(direction)


path = [
    Dir.Right, Dir.Down, Dir.Right, Dir.Down,
    Dir.Right, Dir.Down, Dir.Up, Dir.Right,
    Dir.Up, Dir.Right, Dir.Up, Dir.Right,
]

for direction in path:
    advance(direction)

The while loop mines until the gold ore disappears completely, and the path list connects the gold below to the exit above in sequence.

Chapter 3: Solving Limited Actions and Randomized Ore

Every level in Chapter 3 limits the number of mining actions. In Levels 12, 13, and 15, the ore positions change when you restart the level. Instead of memorizing locations, use look() to read the resource type and if/elif/else to choose the required action.

Start Python Mine Chapter 3
11
CHAPTER 3 · STAGE 11

Two Chances: Mine Only When the Ore Is Gold

Objective: Use only two mining opportunities to collect 2 Gold and reach the ladder.

mine() at most 2 times At least 2 Gold Target coordinate (10, 3)

The tunnel contains a mix of gold and iron ore. Using mine() on iron wastes one of your limited opportunities, so mine only when the resource ahead is Res.Gold. Remove the iron and the soft rocks beneath it with clear() to open the path.

Level 11 game screen with iron and gold ore mixed in a straight tunnel
Level 11 Two Chances game screenIron and gold ore are mixed in one row, so inspect each resource before mining.
View Level 11 Example Solution
while not is_downstairs():
    if look(Dir.Right) == Res.Gold:
        mine()
    else:
        clear()

    move(Dir.Right)

The code inspects every space until it reaches the ladder, so it calls mine() exactly twice and only on gold.

12
CHAPTER 3 · STAGE 12

Dark Mining 1: Read Ore HP and Mine Precisely

Objective: Mine the large gold ore in its randomized location three times, collect 3 Gold, and reach the ladder.

mine() at most 3 times At least 3 Gold Randomized placement

The positions of the large gold ore and the iron and coal decoys can change when you restart the level. Find the gold with look(), read its remaining HP with look_hp(), and mine only that many times.

Level 12 Dark Mining 1 game screen with only the area around the miner illuminated in a dark tunnel
Level 12 Dark Mining 1 game screenThis nighttime mine shows only the area around the miner, and the positions of GoldLarge and the decoy ores change when the level restarts.
View Level 12 Example Solution
while not is_downstairs():
    if look(Dir.Right) == Res.Gold:
        for _ in range(look_hp()):
            mine()
    else:
        clear()

    move(Dir.Right)

The large gold ore has 3 HP, so the code mines three times only when it finds gold. The same code works even when the position changes.

13
CHAPTER 3 · STAGE 13

Dark Mining 2: Select Two Ores with or

Objective: Collect 2 Iron and 2 Gold in the randomized tunnel, then reach the ladder.

mine() at most 4 times Iron 2 + Gold 2 or operator

You need to mine when the resource is either iron or gold, so join the two comparisons with or. Coal is not part of the objective, and you have only four mining opportunities, so remove it with clear(). The positions of the six ores change when you restart.

Level 13 Dark Mining 2 game screen where iron, gold, and coal must be distinguished in a dark tunnel
Level 13 Dark Mining 2 game screenInspect the resource ahead in the randomized dark tunnel and select only Iron and Gold.
View Level 13 Example Solution
while not is_downstairs():
    target = look(Dir.Right)

    if target == Res.Iron or target == Res.Gold:
        mine()
    else:
        clear()

    move(Dir.Right)

The code mines only the two Iron and two Gold resources, for a total of four mining actions, so it stays within the limit.

14
CHAPTER 3 · STAGE 14

Limited Actions: Use if/elif to Perform Only Necessary Actions

Objective: Collect 3 Iron and reach the ladder within the mining and clearing limits.

mine() at most 3 times clear() at most 4 times Target coordinate (12, 3)

Call mine() for iron ore and clear() for an empty soft rock. In an open tunnel space that meets neither condition, move without calling an action function so you can stay within the exact limits.

Level 14 Limited Actions game screen with iron ore and soft rocks placed along a long tunnel
Level 14 Limited Actions game screenAct only on the three iron ores and four soft rocks in the long tunnel.
View Level 14 Example Solution
while not is_downstairs():
    target = look(Dir.Right)

    if target == Res.Iron:
        mine()
    elif target == Res.SoftRock:
        clear()

    move(Dir.Right)

The code acts only on the three iron ores and four soft rocks on the map, satisfying both limits.

15
CHAPTER 3 · STAGE 15

Pressure Plate - Blue Gem: Explore a Randomized Maze with a Function

Objective: Use the pressure plate to turn on the lights, explore the maze, collect one Gold and one GemBlue, and reach the ladder.

mine() at most 2 times Gold 1 + GemBlue 1 def · randomized placement

The positions of the gold, blue gem, iron, and coal change when you restart. In each section, inspect the next space, mine only gold or blue gems, remove everything else, and then move. Defining the shared process as an explore() function lets you reuse it across all five tunnel sections.

Note: The pressure plate turns on the visual effect that illuminates the darkness. To clear the level, you must meet all three actual conditions: collect Gold, collect GemBlue, and reach the ladder.

Level 15 game screen showing gold and a blue gem in a maze illuminated by a pressure plate
Level 15 Pressure Plate - Blue Gem game screenImmediately after stepping on the pressure plate and turning on the lights, you can see the possible Gold and GemBlue locations in the maze.
View Level 15 Example Solution
def explore(direction, steps):
    for _ in range(steps):
        target = look(direction)

        if target == Res.Gold or target == Res.GemBlue:
            mine(direction)
        else:
            clear(direction)

        move(direction)


explore(Dir.Right, 6)
explore(Dir.Down, 2)
explore(Dir.Left, 6)
explore(Dir.Down, 2)
explore(Dir.Right, 6)

The miner passes every candidate space in the maze and mines only the two target ores. Because the code inspects each resource type directly, it still works when the placement changes.

What to Check When Your Code Does Not Run

  1. Check the direction passed to look(). look() requires a direction, so write it as look(Dir.Right), for example.
  2. Do not use a ladder loop in Levels 7-9. These three levels have no target ladder, so a while not is_downstairs() loop will never end.
  3. Distinguish clear() from mine(). Using clear() on ore opens the path, but it does not add that resource to your inventory.
  4. Check both the ore size and its actual HP. By default, Small, Medium, and Large have 1, 2, and 3 HP and give you 1, 2, and 3 resources when fully mined. However, there are exceptions with separately assigned HP, such as the CoalMedium decoy in Level 9.
  5. Do not memorize positions in randomized levels. Placements change when Levels 12, 13, and 15 restart, so choose actions based on the result of look().
  6. Do not spend limited actions on empty spaces. Failed mine() or clear() calls may still count against the action limit.
  7. Check both collection and arrival conditions. Levels 10-15 all require you to collect the target resources and reach the ladder.
  8. You cannot pass through hard rock. Mine ore on HardRock from an adjacent space. The hard rock itself remains even after the ore disappears.
01 / READ

Start with the line that reports the error

Check the function name, parentheses, direction argument, and indentation in order to find syntax errors quickly.

02 / TRACE

Trace one loop iteration at a time

Record the current position and the resource in the next space on paper to find where the movement and action order diverge.

03 / COMPARE

Compare the solution's structure

Rather than memorizing all the code, compare only the missing condition or loop stopping point in your code with the example.

04 / RETRY

Test again with randomized placements

If your code clears Levels 12, 13, and 15 after several restarts, you solved them based on state rather than position.

Compare Problem-Solving Processes in Class

CLASSROOM WORKFLOW

In a Codedash class, instructors can check each student's current level and completion progress. Using Request Help submits the student's current code before the level is cleared, while clearing the level submits the final code. Instructors can open and run these submissions to see whether the student is stuck on the movement path, ore identification, or loop termination.

First, let the student revise the code using only the hint. If they are still stuck, compare their code with this guide's example solution one line at a time. This makes it easier to explain why each condition and loop is needed instead of simply copying the answer.

Enter the First Python Mine Tunnel Now

All three chapters and 15 current Python Mine levels are free to play. The short stages progress from movement to mining, conditional logic, and randomized exploration.

Start Python Mine Level 1

The next chapter unlocks after you complete all five levels in the current chapter.

Frequently Asked Questions

How many Python Mine levels are currently available?

The current game has five levels in each of Chapters 1, 2, and 3, for a total of 15. This guide covers all 15 levels that are currently playable.

Is the code in this guide the only correct answer?

No. Many different programs can satisfy the same objective and action limits. This guide provides example solutions that make the execution order and the role of each syntax feature easy for beginners to follow.

Can I solve the same levels with block coding?

Yes. In Python Mine, you can switch between block coding and Python code. You can first build loops and conditional structures with blocks, then compare them with Python indentation.

Why does look() produce an error without an argument?

look() requires you to specify which direction to inspect. To check the right side, write look(Dir.Right).

The ore positions in Levels 12, 13, and 15 differ from the solution screenshots.

This is expected. The resource placements in these three levels can change when you restart. Instead of following fixed coordinates, use a solution that calls look() to inspect the current resource.

I removed the ore, but my collected resource count did not increase.

clear() removes soft rocks and any ore on top of them, but it does not collect resources. Fully mine target ore with mine() until its HP reaches 0.

Can I select every chapter immediately?

Every chapter is free, but they unlock in order. Completing the five levels in Chapter 1 unlocks Chapter 2, and completing Chapter 2 unlocks Chapter 3.