What am I missing on this spyder Loan Calculator?
<p>IÂ´m learning Python at one of my college classes and I was asked to create a "Loan Calculator".... I might have an idea but IÂ´m not sure how to fix an error that IÂ´m getting  <code>TypeError: 'float' object is not subscriptable</code></p>

<p>This is the announcement
The user has to enter the cost of the loan, interest rate and the number of years of the loan.
Calculate the monthly payments with the following formula:</p>

<pre><code>M = L[i(1+i)^n]/[(1+i)^(n)-1]
Data:
M = monthly payment
L = loan amount
i = interest rate (remember that 5%, i = 0.05)
n = number of payments
</code></pre>

<p>And this is my code:</p>

<pre><code># Loan Calculator
# Equation: M = L[i(1+i)^n]/[(1+i)(n)-1]          

print("Loan Calculator")
L = float(input("Loan amount: "))
i = float(input("Interest rate: "))
# Remember: 5% ---&gt; i=0.05
n = float(input("Number of payments: "))
M = (L[i*(1+i)**n]/[(1+i)**(n)-1])
# M = Monthly payment

print("Monthly payment: " + M)
</code></pre>

<p>PS: I first thought I was missing convert "M" into a string, but after I changed to</p>

<pre><code>print("Monthly payment: " + str(M))
</code></pre>

<p>I'm still getting the same error... Please help!</p>

<p>Needed a few changes: </p>

<pre><code># Loan Calculator
# Equation: M = L[i(1+i)^n]/[(1+i)(n)-1]          

print("Loan Calculator")
L = float(input("Loan amount: "))
i = float(input("Interest rate: "))
# Remember: 5% ---&gt; i=0.05
n = float(input("Number of payments: "))
M = L*(i*(1+i)**n)/((1+i)**(n)-1)
# M = Monthly payment

print("Monthly payment: " , M)
</code></pre>

<p>Using some arbitrary values:</p>

<pre><code>Loan Calculator
Loan amount: 1000
Interest rate: 9 
Number of payments: 100 
('Monthly payment: ', 9000.0)
</code></pre>

python