I have the following a markdown file "loan.md":
#### <u>Loan data:</u>
+ Loan amount: {amount}
+ Loan term: {term}
+ Annual istallments: {instalments}
+ Loan interest rate: {rate}
#### <u>Monthly loan installment:</u>
+ Monthly payment: {payment}
#### <u>Formula to calculate the monthly loan installment:</u>
\[
P = A \times\frac{r_i}{1-(1+r_i)^{-t}}
\]
<u>Where:</u>
\[
r_k = \frac{r}{i}
\]
+ $P$ : Monthly payment.
+ $A$ : Loan amount.
+ $r$ : Interest rate.
+ $i$ :Annual istallments.
+ $t$ : Loan term.
I have the following script in python
loan_data = {'amount':'10000.00',
'term':'60',
'installments':'12',
'rate':'5,95%',
'payment':'193,10'
}
with open('loan.md') as f:
text = f.read()
text = text.format(**loan_data)
out_file = open('output.md', 'w')
out_file.write(text)
When I run the script a get an error the following error message:
Traceback (most recent call last):
File "loan.py", line 10, in <module>
text = text.format(**loan_data)
KeyError: 'r_i'
I know that the error is produced by the Latex in the markdown
It is possible to load a markdown file like the one above in python and fill the replacement field with data?