String
Also known as: text, str, character sequence
A data type that represents a sequence of characters (text), enclosed in quotation marks. Most programs work with text — user input, messages, file contents, and web pages are all strings.
💡 Intuition
A string is text in code — anything between quotes. Numbers inside quotes are text too: '42' is a string, not a number.
Core Idea
Strings are sequences — you can access individual characters by index, search for substrings, and combine strings.
🔬 Example
🎯 Why It Matters
Most programs work with text — user input, messages, file contents, and web pages are all strings.
⚠️ Common Confusion
'123' is a string, not a number. You can't do math with it until you convert it: int('123') gives the number 123.
Related Concepts
Prerequisites
Next Steps
How String Connects to Other Ideas
To understand string, you should first be comfortable with assignment and data types. Once you have a solid grasp of string, you can move on to boolean.
Go Deeper
Frequently Asked Questions
What is String in CS Thinking?
A data type that represents a sequence of characters (text), enclosed in quotation marks.
Why is String important?
Most programs work with text — user input, messages, file contents, and web pages are all strings.
What do students usually get wrong about String?
'123' is a string, not a number. You can't do math with it until you convert it: int('123') gives the number 123.
What should I learn before String?
Before studying String, you should understand: assignment, data types.