-4

I have this code:

balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
monthly_interest_rate = annualInterestRate / 12.0
for counter in range(1, 12):
    payment = monthlyPaymentRate * balance
    monthly_unpaid_balance = balance - payment
    balance = monthly_unpaid_balance + (monthly_interest_rate * monthly_unpaid_balance)
    print('Month: {}\nMinimum monthly payment: {}\nRemaining balance:{}'.format(
              counter, round(payment, 2), round(balance, 2)))

How can I calculate Total paid(sum of all minimum monthly payments)?

Oleksandr Firsov
  • 1,428
  • 1
  • 21
  • 48

2 Answers2

2

I think you are calculating for only 11 months instead of 12.

for counter in range(1, 12+1)
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
1

You copy-pasted wrongly from my answer. The range should be until 13.

Community
  • 1
  • 1
Mihai Maruseac
  • 20,967
  • 7
  • 57
  • 109