Python String Game: Word Locks
Every door in the museum has a word lock. Build the right string in Python and it clicks open.
About this python string game
String exercises are usually a list of tasks with no feedback until you check the answer. Word Locks puts each one behind a door: type the word, loop over its letters, join two halves, reverse it with a slice, shout or whisper it with upper() and lower(), and finally shorten it one letter at a time with a while loop. The words change every run, so the code has to work for any word, not just one.
How to play Word Locks
- Each door shows what it wants. Open it with
unlock(word). - Later levels give words through
note(),secret()andnext_word()— they change every run. - A wrong word buzzes and the door stays shut; the right one opens it.
- Open every door in the room to finish.
All 6 levels — what each one teaches
| # | Level | Python idea | Goal |
|---|---|---|---|
| 1 | First Locks | Strings | Open the three doors: sun, moon and star. |
| 2 | Letter Lockers | for loops over strings | Open six lockers with the letters of "python", in order. |
| 3 | Two Halves | Joining strings | Read each note and unlock 3 doors with the joined words. |
| 4 | Mirror Room | Functions and slicing | Unlock 3 mirror doors with each secret word backwards. |
| 5 | Shout or Whisper | if statements | Capitals for long words, small letters for short ones. |
| 6 | The Echo Hall | while loops | Unlock with the word, then shorter and shorter, until none is left. |
New to these ideas? Each level pairs with a free lesson: loops, variables, functions and conditions. When you finish, try Python Quest next.
More Python adventure games
- Python adventure game — Python Quest
- Python space shooter game — Code Defender
- Python turtle online — Python Painter
- Karel python — Robot Factory
- Python farming game — Python Farmer
- Python treasure hunt game — Treasure Hunter
- Python math game — Math Island
- Python rocket game — Space Explorer
- Python strategy game — Castle Builder
Or browse all the Python coding games.
Frequently asked questions
Are these Python string exercises for beginners?
Yes. The first level only needs a quoted word; the last uses slicing and a while loop. If slicing is new, the free tutorials cover it first.
Which string methods does Word Locks use?
upper(), lower() and len(), plus + to join and slices such as [::-1] and [:-1].
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