If I have a variable and want to use the string formatting, I would use:
print 'r_0 =%02f ' %(variable1)
which works fine. However I would like to use "math mode" inside print
.
i.e.
print r'$r_{0}=%02f \pm %02f$' %(variable1,variable2)
The above doesn't seem to work. It just prints the values of variable1
and variable2
correctly, but it doesn't print r_0
and \pm
as it should. i.e. it prints
$r_{0}=18.966 \pm 0.424698$
My question is, how to make the subscript (r_{0})
and \pm
work!