0Pricing
Coding for Kids · Lesson

Decoding a Message

Turn code back to text.

Decoding a Message is a free Coding for Kids lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Crack the Code! 🔓

Your friend sent you a secret message! 📨 Now you need to decode it back into normal words.

Let's become code breakers! 🕵️

Decode Is the Opposite 🔄

To encode we ADD the shift. To decode we SUBTRACT it!

coded = 'D'
shift = 3
print(chr(ord(coded) - shift))

One Letter Back ⬅️

Subtracting the key turns the secret letter back to normal!

print(chr(ord('K') - 3))

Loop to Decode 🔂

Go through each coded letter and shift it back.

coded = 'KLGH'
shift = 3
for letter in coded:
    print(chr(ord(letter) - shift))

Glue It Together 🧩

Build the decoded word in an empty box.

coded = 'KLGH'
shift = 3
plain = ''
for letter in coded:
    plain += chr(ord(letter) - shift)
print(plain)

Make a Decode Tool 🛠️

Wrap the decoder in a function for easy reuse!

def decode(coded, shift):
    plain = ''
    for letter in coded:
        plain += chr(ord(letter) - shift)
    return plain
print(decode('KLGH', 3))

Encode Then Decode 🔁

Encode a word, then decode it. You should get the original back!

def encode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) + s)
    return out
def decode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) - s)
    return out
secret = encode('HELLO', 4)
print('Coded:', secret)
print('Back:', decode(secret, 4))

Wrong Key, No Luck 🚫

If you use the WRONG key, the message stays scrambled. The key is the secret!

def decode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) - s)
    return out
print(decode('KLGH', 1))

Decode a Mystery 🔍

Here's a coded message with key 2. What does it say?

def decode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) - s)
    return out
print(decode('JCRRA', 2))

Send Secret Notes 📬

Now you and a friend can swap secret notes with a shared key! 🤝

def decode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) - s)
    return out
print('Message:', decode('OQQP', 2))

Try Your Own 🎯

Decode this one with key 3 and read the surprise!

def decode(msg, s):
    out = ''
    for c in msg:
        out += chr(ord(c) - s)
    return out
print(decode('ZRZ', 3))

Quick Check ✅

To decode a shifted message, what do you do?

Code Breaker! 🏆

You did it, secret agent! You learned to:

  • Decode by subtracting the key ⬅️
  • Build a decode function 🛠️
  • Encode then decode to get the original 🔁
  • Why the key must stay secret 🗝️

You finished Secret Code Maker! 🎉🤫

Frequently asked questions

Is the “Decoding a Message” lesson free?

Yes — the full text of “Decoding a Message” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Decoding a Message”?

Turn code back to text. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Coding for Kids?

No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Decoding a Message” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Coding for Kids lesson?

Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Is a Code?
  2. Shifting Letters
  3. Encoding a Message
  4. Decoding a Message
← Back to Coding for Kids