Lesson 5: Working with Strings
A string is any text in Python — names, sentences, words, even single characters. Strings are wrapped in quotes and have tons of useful built-in tricks.
Key Concepts
Creating Strings
Surround text with single or double quotes to make a string: 'Hello' or "Hello". Both work the same. Use double quotes when your text contains an apostrophe, like "It's great!".
String Concatenation
You can join strings together with +: 'Hello' + ' ' + 'World' gives 'Hello World'. This is called concatenation — a fancy word for sticking strings together.
Useful String Methods
Strings have built-in methods. 'hello'.upper() returns 'HELLO'. 'WORLD'.lower() returns 'world'. len('Python') returns 6 — the number of characters.
🆕 Try It: Live Python
Experiment with your own strings!
✅ Check Your Understanding
1. What does len('Python') return?
2. How do you join two strings?
3. What does 'hello'.upper() return?