Strings: Text in Your Code! 🔤
Any time you use words, names, or sentences in your code — that’s a string! Think of it as a necklace of letters all joined together!
Letters Joined Together Like a Necklace!
Any text you write in code — in quote marks — is a string!
When I first saw the word “string” in code, I thought it meant a piece of thread! My teacher laughed and said — “Think of it like a friendship bracelet.” Each bead is a letter. Put them all together and you get a word or sentence. That’s a string! 😊
You See Strings Everywhere!
Any text in quotes in your code — that’s a string!
Your Name
Your name is text — so in code, it’s a string. Always wrap it in quotes!
name = “Sara”A Message
Chat messages, greetings, alerts — any sentence your program shows is a string!
msg = “Hello, welcome!”Email Address
Even though emails have numbers and symbols — they’re still text, so they’re strings!
email = “[email protected]”Game Character Name
In every game, character names are stored as strings — from Mario to Pikachu! 🎮
hero = “Pikachu”Website URL
Web addresses are strings too! Your browser reads a string to find the right website!
url = “google.com”Interactive String Builder!
Type letters using the keyboard below — watch your string grow!
Click letters to build your string — then press Run to see the output!
4 Things You Can Do With Strings!
Strings can do way more than just hold text — check these out!
Join Strings Together!
You can add two strings using + — just like gluing words together! This is called concatenation.
first = "Hello" second = " World" print(first + second) # Hello World
Find How Long It Is!
Use len() to count how many characters are in your string — including spaces!
name = "Sara" print(len(name)) # 4 characters!
Make It UPPERCASE!
Use .upper() to turn all letters into capitals. Perfect for shouting or headings!
word = "hello" print(word.upper()) # HELLO
Make It lowercase!
Use .lower() to turn everything into small letters. Great for comparing names!
word = "HELLO" print(word.lower()) # hello
3 Mistakes Every Beginner Makes!
I made all of these — so you don’t have to! 😄
4 questions · pick an answer to check!
⭐ Remember This!
A string is any text in quote marks in your code
Use + to join two strings together (concatenation)
Use len() to count how many characters a string has
Always use quote marks — single or double — around your string!
