String Methods
STEP 3 IS HERE, and this is where strings stop being simple text and start becoming
transformers.
Not the robot kindโฆ but honestly, just as powerful.
This step gives teens the tools to clean, format, fix, and style text so their games feel polished and professional.
Letโs unleash it.
Alright coder โ youโve created strings, youโve combined themโฆ Now itโs time to upgrade them.
String methods are built-in tools that let you:
- shout in ALL CAPS
- whisper in lowercase
- fix messy input
- check if something is a number or a letter
- clean up player names
- format dialogue
- make your game text look GOOD
These are the โsuperpowersโ of strings.
1. .upper() โ SHOUT MODE
message = "danger ahead"
print(message.upper())
Output:
DANGER AHEAD
Perfect for boss fights.
2. .lower() โ whisper mode
name = "MARK"
print(name.lower())
Output:
mark
Useful for comparing input.
3. .title() โ Fancy Name Mode
player = "ava the brave"
print(player.title())
Output:
Ava The Brave
Your game now has style.
4. .strip() โ Clean Up Messy Input
Players type weird stuff.
Spaces everywhere.
Chaos.
name = " Mark "
print(name.strip())
Output:
Mark
Clean. Polished. Professional.
5. .replace() โ Swap Words Like a Magician
text = "You found a rock."
print(text.replace("rock", "potion"))
Output:
You found a potion.
Your game now edits itself.
6. .startswith() and .endswith() โ Text Detectives
command = "attack goblin"
print(command.startswith("attack"))
print(command.endswith("goblin"))
Perfect for command-based games.
7. Why These Matter for Games
String methods let you:
- clean player names
- format dialogue
- detect commands
- build menus
- create polished UI text
- make your game feel intentional This is where your game stops feeling โbeginnerโ and starts feeling designed.
Mini Challenge
Take the string ” the lost sword “
Clean it, capitalize it, and print it as:
The Lost Sword
Boom.
Your game now has elegant item names.
You now know how to:
- transform text clean input
- format names
- detect patterns
- polish your gameโs dialogue and UI
Ready for Step 4, where we dive into string slicing โ cutting, trimming, extracting, and analyzing text like a coding ninja?

