I have a string and I would like to add a \
before some characters.
I have my string in terms_string and what I do is:
charmap = {':', '(', ')', '{', '}', '[', ']', '<', '>', '/', '\\', '='}
for key in charmap:
terms_string = terms_string.replace(key, '\\'+key)
Everything works fine but I get a \\
instead a \
.
For example for the charmap I get
{'(', ')', '/', ':', '<', '=', '>', '[', '\\', ']', '{', '}'}
insted
{'(', ')', '/', ':', '<', '=', '>', '[', '\', ']', '{', '}'}
This only happens with the character \, not with the others.
Any idea why this is happening? Python configuration maybe? Thanks!