I need to automatize the writing of a latex file. To do this, I need to format a string already containing "{" and "}" characters. To make an example, consider the string
a = "\begin{theorem} Consider the integral $$ \int_a^b {}dx $$bla bla bla. \end{theorem}"
functions = ["x^2 -2", "e^{-x} + 7"]
f = functions[1]
a.format(f)
This code gives an error since there are already parenthesis "{}" filled with the word "theorem" in the beginning. If I erase "\begin{theorem}
" and "\end{theorem}
" the code works.
How can I format the string already containing the substring "{something}
"?
I am using python 3.8, anaconda and spyder.
I could split the string in two, or three; or I could consider the word "theorem" as an argument of the format method, but can I do it directly? in other words which is the fastest solution?