Jun-30-2018, 03:03 AM
I first used the following code
Python is giving me an error when I try the second posted code, what is wrong with it??
balance=42 annualInterestRate=.2 monthlyPaymentRate=0.04 month=1 while month <=12: balance=(balance+balance*(annualInterestRate/12))-(monthlyPaymentRate*(balance+balance*(annualInterestRate/12))) print('Month ' +str(month) + ' Remaining balance: '+ str(balance) month+=1I then realized I want the balance in line 9 to round to 2 decimal places so I edited my code to
balance=42 annualInterestRate=.2 monthlyPaymentRate=0.04 month=1 while month <=12: balance=(balance+balance*(annualInterestRate/12))-(monthlyPaymentRate*(balance+balance*(annualInterestRate/12))) print('Month ' +str(month) + ' Remaining balance: '+ str(round(balance, 2)) month+=1Note line 9, the only thing I changed was to print the balance as rounded.
Python is giving me an error when I try the second posted code, what is wrong with it??