s[0] = 'H' raises a TypeError. Write replace_char_at(s, index, new_char) that returns a new string with the character at index swapped for new_char, built entirely from slices (never mutating s).s = 'hello', index = 0, new_char = 'H'
'Hello'
The character at index 0 is swapped; everything else is copied through.
s = 'cat', index = 2, new_char = 'r'
'car'
Works for any valid index, including the last one.
Build the result as s[:index] + new_char + s[index+1:].
This never touches `s` itself — it constructs a brand-new string object.