String
A piece of text, written between quotes, e.g. "hello".
A string is text wrapped in single or double quotes — both styles are equivalent. You can join strings with +, read one character by position with text[0], take a slice with text[1:4], and call built-in methods such as .upper() or .replace().
Strings are immutable: a method never changes the original, it returns a brand-new string.
greeting = "hello"
print(greeting.upper()) # methods return a NEW string
print(greeting[0]) # index: the first character
print(f"{greeting}, world!") # f-string formatting
Output
HELLO h hello, world!
Where this shows up in real Python
Strings show up whenever you touch text: cleaning user input, building filenames, formatting a report line, or reading a row from a CSV.
Commonly used String tools
str is a built-in type with many methods — the ones you’ll use most:
.upper() / .lower()— return an upper/lowercased copy.strip()— remove surrounding whitespace.replace(old, new)— swap one substring for another.split(sep)— break text into a list of parts' '.join(parts)— join a list of strings back together.startswith(x) / .endswith(x)— test how the text begins or endsf'{value}'— f-strings drop values straight into text
Official documentation: Python Library Reference: Text Sequence Type — str