对于某些背景,我已经编程多年,但直到现在才真正接触过 Python,我不确定这里出了什么问题,IDLE 正在标记第 24 行(最后一行):
'''
Test Cases
'''
balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
'''
Variables
'''
previousBalance = 0
monthlyInterestRate = 0
minMonthlyPayment = 0
totalPaid = 0
m = 1
while (m != 12):
monthlyInterestRate = annualInterestRate / 12
minMonthlyPayment = monthlyPaymentRate * previousBalance
balance = (previousBalance - minMonthlyPayment) * (1 + monthlyInterestRate)
totalPaid = totalPaid + minMonthlyPayment
previousBalance = balance
m += 1
print('Month: ' + str(m))
print('Minimum monthly payment: ' + str(minMonthlyPayment))
print('Total paid: ' + str(round(totalPaid, 2))
print('Remaining balance: ' + str(round(balance, 2)) #Flagging Here
如果有人对为什么最后一个打印功能会导致任何问题有任何想法,请告诉我。