Coding Python
Home›Python Coding Games›Treasure Hunter

Python Treasure Hunt Game: Treasure Hunter

X marks the spot — but only if your code can get there. A pirate island treasure hunt written in Python.

About this python treasure hunt game

A treasure hunt is the classic beginner Python project, usually as a text game with input(). Treasure Hunter turns it into a map you solve with code. The early levels are about walking and digging; then the island starts hiding things — a clue you must store in a variable, signposts that need if/elif, and a final level where three chests move every run and only distance(), direction() and a while loop will find them.

How to play Treasure Hunter

  1. Move the pirate with move(direction, steps) and dig with dig().
  2. Read the level's story: some give a clue, some put signs on the sand.
  3. Run the program — each line is shown as the pirate acts it out.
  4. Dig up every chest; digging in the wrong place wastes a turn.

All 6 levels — what each one teaches

#LevelPython ideaGoal
1X Marks the SpotCalling functionsReach the X and dig up the treasure.
2Gold Coastfor loopsDig up all 5 chests on the beach.
3The Old ClueVariablesUse the clue to find the hidden treasure.
4The Captain's LogFunctions with inputsDig up all 4 chests using a go_dig(steps) function.
5Follow the Signsif / elifFollow the 6 signs, then dig where the trail ends.
6Treasure Feverwhile loopsFind all 3 hidden treasures.

New to these ideas? Each level pairs with a free lesson: loops, variables, functions and conditions. When you finish, try Math Island next.

Prefer to code on your phone? Keep practising on Android: the free Coding Python app is a full Python 3 editor and interpreter with 30 examples and 12 challenges.
Get the free app

More Python adventure games

Or browse all the Python coding games.

Frequently asked questions

Can I build my own Python treasure hunt game?

Yes — a text treasure hunt with input(), a dictionary of rooms and a loop is a great first project. The simple Python games guide has similar games to start from.

Is Treasure Hunter good for kids?

Yes. It is gentle, has no chat, ads or accounts inside the game, and the first levels need only one command per line.

Is it free, and do I need to sign up?

It is free with no account. The game runs in your browser and saves your progress in this browser only.

Does it run real Python?

Yes. Your code runs on CPython compiled to WebAssembly (Pyodide) inside the page. Errors are real Python errors, and an endless loop is stopped after a few seconds instead of freezing the tab.

Does it work on a phone?

Yes. On narrow screens the editor sits at the bottom of the game. For longer coding sessions on Android, the free Coding Python app has a full Python editor.

Take Python with you

Coding Python packs a real Python 3 compiler, 30 example programs, 112 quiz questions and 12 self-checking challenges into one free Android app.

Get it on Google Play
Coding Python app icon