Coding Python
Home›Python Coding Games›Word Locks

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

  1. Each door shows what it wants. Open it with unlock(word).
  2. Later levels give words through note(), secret() and next_word() — they change every run.
  3. A wrong word buzzes and the door stays shut; the right one opens it.
  4. Open every door in the room to finish.

All 6 levels — what each one teaches

#LevelPython ideaGoal
1First LocksStringsOpen the three doors: sun, moon and star.
2Letter Lockersfor loops over stringsOpen six lockers with the letters of "python", in order.
3Two HalvesJoining stringsRead each note and unlock 3 doors with the joined words.
4Mirror RoomFunctions and slicingUnlock 3 mirror doors with each secret word backwards.
5Shout or Whisperif statementsCapitals for long words, small letters for short ones.
6The Echo Hallwhile loopsUnlock 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.

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

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
Coding Python app icon