Encoding a Message
Turn text into code.
Encoding a Message is a free Coding for Kids lesson on CoddyKit — lesson 3 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.
Encode a Message! 📨
Now let's turn a whole secret message into code! 🔐 We'll shift every letter using our cipher.
Our Message 📝
Start with a message to hide.
message = 'HIDE'
print('Secret message:', message)Pick the Key 🗝️
Choose a shift key. Keep it secret — only your friend should know it!
shift = 3
print('Shift key:', shift)An Empty Box 📦
Make an empty string to collect the coded letters.
coded = ''
print('Start:', coded)Loop and Shift 🔂
Go through each letter, shift it, and add it to the box!
message = 'HIDE'
shift = 3
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
print(coded)Try a Longer Message 📜
Encode a bigger word! Spaces will shift too — that's okay for now.
message = 'SECRET'
shift = 2
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
print(coded)Make It a Tool 🛠️
Wrap the encoder in a function so you can reuse it!
def encode(message, shift):
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
return coded
print(encode('HI', 3))Encode Many Words 🔁
With the tool, encode lots of words easily!
def encode(message, shift):
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
return coded
print(encode('CAT', 1))
print(encode('DOG', 1))Change the Key 🎚️
A different key gives a totally different code!
def encode(message, shift):
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
return coded
print(encode('SPY', 5))Send to a Friend 📬
Show the secret message ready to send!
def encode(message, shift):
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
return coded
print('Send this:', encode('MEET', 4))Your Secret Word 🤫
Encode your own secret word and a key only YOU know!
def encode(message, shift):
coded = ''
for letter in message:
coded += chr(ord(letter) + shift)
return coded
print(encode('PIZZA', 3))Quick Check ✅
Why do we start with an empty string coded = ''?
Encoder Expert! 🏆
Fantastic! You learned to:
- Loop through a whole message 🔂
- Build a coded string letter by letter 🧩
- Wrap it in a reusable function 🛠️
- Change the key for new codes 🗝️
Next: decode a message back to normal! 🔓
Frequently asked questions
Is the “Encoding a Message” lesson free?
Yes — the full text of “Encoding 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 “Encoding a Message”?
Turn text into code. 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 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Encoding 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
- What Is a Code?
- Shifting Letters
- Encoding a Message
- Decoding a Message