(a_string)
return a_string.translate(str.maketrans({
        "\n": r"\\n",
    }))
Some characters create problems when written to file
Some characters create problems when written to file
Some characters create problems when written to file
def escape_chars(a_string):
    """Some characters create problems when written to file"""
    return a_string.translate(str.maketrans({
        "\n": r"\\n",
    }))
def escape_chars ( a_string ) : return a_string . translate ( str . maketrans ( { "\n" : r"\\n" , } ) )