对于某些背景,我已编程多年,但直到现在才真正触及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
如果有人对上次打印功能导致任何问题的原因有任何想法,请告诉我。
答案 0 :(得分:3)
你在第23行末尾遗漏了一个括号。
答案 1 :(得分:0)
作为提示,下次不要在2.7中将括号括在打印功能周围。它不能有效地工作。它也清除了这样的混乱,我知道因为它总是发生在我身上。但是,你应该在3.x。
中完成