Strings in Python
A string (str) is Python's type for text — any sequence of characters wrapped in quotes. Strings are immutable, meaning once created they can never be changed in place; every operation that seems to "modify" a string actually builds and returns a brand new one, leaving the original untouched.
Strings also behave as sequences, so individual characters can be accessed by position (indexing), the same way items in a list can be — a connection that becomes clearer once slicing is covered later in this course.
Create a string
Wrap text in single, double, or triple quotes.
Access characters by index
my_string[0] gets the first character — indexing starts at 0.
Combine strings
Concatenate with +, or repeat with *.
Methods return new strings
Because strings are immutable, calls like .upper() or .replace() return a new string rather than changing the original.
Measure length with len()
Counts every character, including spaces and punctuation.
greeting = "Hello"print(greeting[0])print(greeting + ", World!")print(greeting.upper())print(greeting)print(len(greeting))Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Python yourself — building beats watching.