$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #55

Which fix removes the bug?

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