Strings
A string is text written between quotes, single or double, that Python treats as a value.
Used in 129 lessons of the course, from 00.01.
A string is a sequence of characters. You write it between quotes: "hello" or 'hello'. Both forms are the same; pick the one that saves you from escaping the other quote, for example "it's".
If you need the same kind of quote inside, escape it with a backslash: 'it\'s'. Other common escapes are \n (new line) and \t (tab).
Strings are immutable: you don't change an existing one, you create a new one.
You see them everywhere in the course. In print("Python version :", platform.python_version()), the first argument is a string literal: a text label that print shows next to the value. The quotes tell Python "this is data, not a variable name".
Reach for it when: you need to represent text: messages, labels, names or prompts.
Examples
Common mistake
print("Hello)Why: The opening quote has no closing one, so Python can't tell where the text ends.
How to write it: Close the string with the same quote: print("Hello").
Common mistake
word = "cat" word[0] = "b" print(word)
Why: Strings are immutable: you can't change a character in place.
How to write it: Build a new one: word = "b" + word[1:].
