Which fix removes the bug?
s = "hello" s[0] = "H" print(s)
- Rebuild it:
s = "H" + s[1:] - Rebuild it:
s = "H" + s[0:] - Convert first with
s = list(s) - Use
s.replace(0, "H")instead
Python strings are immutable, so build a new string instead of assigning to an index.
Play Problem Solving ▸