.replace(old, new, 1) swaps the first match. A file-renaming tool needs to swap only the last one, for example to change the final - in a date.
Task: write replace_last(text, old, new) that returns text with only the last match of old replaced by new.
old doesn't appear, return text unchanged.old is never empty."aaa", the last "aa" starts at position 1.Once your code passes every test, a reference solution shows up here so you can compare it with yours.