If a string can't be changed in place, how do you 'edit' one — and what makes `print()` different from just peeking at a value?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Strings can't be changed in place, so instead you build a new one. Starting from
word = "car", build a new string equal to "bar" — the first letter replaced by
"b" — and assign it to new_word. The slice word[1:] gives everything from index
1 onward, and + joins strings together.
No assignment into a string position
State that a string cannot be altered after creation, record s[0] = "b" on s = "car" as an error, and mark mutable objects as a later contrast.
Shell peeking versus explicit print()
Record that a bare expression in a file computes its value and shows nothing, then write s = "the", print(len(s)) and print(s[-3]), each result on its own line.
Commas versus concatenation inside print
Give the output of print("the", 3, "musketeers") with its inserted spaces, record the TypeError from print("the" + 3 + "musketeers"), and write the str(3) version.