title: Amortization Schedule on Python
body: <p>I have been working on an amortization schedule using python. however, when I run the code the output does not give me the correct results, instead it appears is looping and printing the same values across, 360 times. Below is the code I wrote.</p>
  <pre><code>import pandas as pd
  import math
  
  p = float(input(&quot;Amount borrowed: &quot;))
  r = float(input(&quot;Annual Interest Rate: &quot;))
  t = float(input(&quot;Payback Period in years: &quot;))
  
  m=(p*(r/12)*(math.pow(1+r/12,12*t)))/(math.pow(1+r/12,12*t)-1)
  print()
  print(&quot;Your payment will be: $&quot;+str(m))
  print()
  print(&quot;Month\tStartingBalance\tInterestCharge\tPayment\tEndingBalance&quot;)
  month=12*t
  month=int(month)
  startingBalance=p
  for i in range(1,month+1):
    interestCharge=r/12*startingBalance
    endingBalance=startingBalance+interestCharge-m
    print(str(i)+&quot;\t$&quot;+str(round(startingBalance,2))+&quot;\t$&quot;+str(round(interestCharge,2))+&quot;\t$&quot;+str(round(m,2))+&quot;\t$&quot;+str(round(endingBalance,2)))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/lrPvN.png" rel="nofollow noreferrer">Output</a></p>