Lesson 5 of 13

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!

H
e
l
l
o
!
🤔 What is a String?

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! 😊

🧵 The string “Hello” — 5 letters joined together!
H
[0]
e
[1]
l
[2]
l
[3]
o
[4]
name = “Hello”

🌍 Strings in Real Life

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”

🎮 Build Your Own String!

Interactive String Builder!

Type letters using the keyboard below — watch your string grow!

⌨️ String Playground

Click letters to build your string — then press Run to see the output!

my_string = 0 chars
Click to type:
# Output will appear here after Run! 🚀

⚡ Cool String Tricks!

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

😅 Common Mistakes

3 Mistakes Every Beginner Makes!

I made all of these — so you don’t have to! 😄

name = Sara
🤔 Without quotes, Python thinks “Sara” is a variable name — not text!
✅ name = “Sara”
msg = “She said “hi” to me”
🤔 Quotes inside quotes confuse the computer — use single quotes inside!
✅ msg = “She said ‘hi’ to me”
result = “5” + 5
🤔 You can’t add a string and a number! Convert first with int() or str().
✅ result = int(“5”) + 5 # → 10

🧠 Quick Quiz!
🎯 Strings Quiz

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!