Junior Codes
Message Harbour

Python f-strings for Kids

Drop variables straight into a message so it changes by itself.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

f-strings, explained simply

Suppose you want to greet every player by name. Writing a separate message for each person would take forever. An f-string lets one message fill itself in.

Put the letter f right before the opening quotation mark, then write a variable name inside curly brackets { }. When the line runs, Python swaps the brackets for the value stored in the variable.

You can put more than one variable in the same message, and even small calculations like {score * 2}.

Example: A message that fills itself in

player = "Asha"
score = 12
print(f"Well done, {player}! You scored {score} points.")

Output

Well done, Asha! You scored 12 points.

Try this

  • Change player to your own name and run it again. The message updates without touching the print line.
  • Remove the f and see what gets printed instead.
  • Add a variable for a pet name and put it in the same sentence.

Practise it in Wonderwild

“Postcards from the harbour”

Mission 7 in Message Harbour, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

What does the f in an f-string stand for?+

It stands for "formatted". It tells Python to look for curly brackets and fill them with values.

Are f-strings better than joining text with +?+

For most messages, yes. They are shorter, easier to read, and they work with numbers without converting them first.

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course