I need use regexp with f-string, for simple code:
import re
def double_swap(txt, c1, c2):
result = [re.sub(fr'[{a}]', c1, c2) if a == c1 else (
   re.sub(fr'[{a}]', c2, c1) if a == c2 else a) for a in txt]
return ''.join(result)
results:
print(double_swap("aabbccc", "a", "b"))  # -> bbaaccc
print(double_swap("**##**", "*", "#"))  # -> ##**##
This code is working on vscode and py 3.7.3, but not working on server, I still have problem:
ERROR:   File "<string>", line 12
    result = [re.sub(fr'[{a}]', c1, c2) if a == c1 else (
                             ^
SyntaxError: invalid syntax
Maybe on server is old version of py?
 
    