Combining Strings
STEP 2 IS HERE, and this is where strings stop being quiet little text blobs and start becoming
dynamic, customizable, game-powered messages.
This is the moment your game learns how to speak with personality.
Letβs crank the energy.
Alright coder β in Step 1, you learned what strings are.
Now we level up.
Because a game that only prints fixed text is like a robot reading a script.
A real game needs to say things like:
- βWelcome, Mark!β
- βYou picked up 3 potions.β
- βThe dragon dealt 12 damage!β
That means your text needs to change depending on the situation.
Enter: string combining.
1. The + Operator β The Classic Combo Move
You can glue strings together using +.
name = "Mark"
print("Welcome, " + name + "!")
Your game now greets players like a friendly NPC.
2. Combining Strings + Numbers (The Gotcha)
Python wonβt let you mix strings and numbers directly.
This will break (that is, you will see an error:( TypeError : can only concatenate str (not “int”) to str):
print("You have " + 5 + " coins.")
Python: βBroβ¦ what?β
You must convert numbers to strings:
print("You have " + str(5) + " coins.")
Boom.
Your game now counts.
3. Using Variables Inside Messages
This is where things get fun.
player = "Ava"
item = "potion"
print(player + " picked up a " + item + "!")
Your game now reacts to whatβs happening.
4. Why This Matters for Games
Dynamic strings let you build:
- battle messages
- item pickups
- shop menus
- story narration
- character dialogue
- quest updates
Basically, everything your game says.
Practice (Your Turn!)
Mini-Challenge
Create a variable for a player name and a variable for an item.
Print a message like:
βAlex found a sword!β
Your game now reacts like a narrator with style.
You now know how to:
- combine strings
- mix variables into messages
- convert numbers to strings
- create dynamic, game-powered text
Your game officially has personality.
Ready for Step 3, where we dive into string methods β the tools that let you transform text, shout in ALL CAPS, whisper in lowercase, and clean up messy input?

