You can use a list comprehension to switch the values that you want
x = "abcd"
''.join(['d' if i == 'a' else 'a' if i == 'd' else i for i in x])
'dbca'
Without a list
x = "abcd"
''.join('d' if i == 'a' else 'a' if i == 'd' else i for i in x)
'dbca'
Timing
In [1]: x = "abcd"*10000000
In [2]: %timeit ''.join('d' if i == 'a' else 'a' if i == 'd' else i for i in x)
5.78 s ± 152 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [3]: %timeit ''.join(['d' if i == 'a' else 'a' if i == 'd' else i for i in x])
4.49 s ± 157 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
It turns out the list comprehension is slightly faster.