Ad

You need to swap two substrings in passed string.

For example:
if you have a string like "Red is not Blue" and asked to swap "Blue" and "Red", you must return "Blue is not Red"

def swap(string, a, b):
    return string.replace(a, '<tmp>').replace(b, a).replace('<tmp>', b)