Calculating how long it will take to pay off a loan

  python

I’m stuck in my exercise about how long it will take to pay off a loan. I’m trying to do a loop calculating the interest and new balance after each monthly payment. Here what’s I have so far:

def conta ():
  total = float(input('How much do you want to borrow?'))
  qtoPg = float(input('What is the monthly payment amount?'))
  annualInterest = float(input('What is the annual interest rate expressed as a percent?'))
  rateMonth = (annualInterest*0.01)/12
  tjm = total*rateMonth
  nbalance = total+tjm-qtoPg
  while nbalance <= qtoPg:
    tjm = nbalance*rateMonth
  print (nbalance)

Source: Python Questions

LEAVE A COMMENT