我有功课要做,我做了。我95%肯定它是一个核心代码。我不知道为什么但不幸的是我在其中一行中得到了Syntax错误。这是我的代码:
month = 1
totalPaid = 0
while month <= 12:
print('Month: ' + str(month))
print('Minimum monthly payment: ' + str(round(monthlyPaymentRate * balance), 2)
balance = round((balance - (monthlyPaymentRate * balance)) * (1 + (annualInterestRate/12)),2)
print('Remaining balance: ' + str(round(balance, 2)))
month = month + 1
totalPaid = totalPaid + round((monthlyPaymentRate * balance), 2)
print('Total paid: ' + str(totalPaid))
print('Remaining balance: ' + str(balance))
我在这一行收到了语法错误:balance = round((余额 - (monthlyPaymentRate *余额))*(1 +(annualInterestRate / 12)),2)。它可能是非常简单的东西,但我是Python的新手,无法理解究竟是什么问题,我知道Python对空间和缩进非常敏感,我对此非常谨慎。有什么建议吗?
答案 0 :(得分:6)
print('Minimum monthly payment: ' + str(round(monthlyPaymentRate * balance), 2)
有三个开放的parens,但有两个紧密的parens。