Python 2中的语法错误

2024-09-27 07:32:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我有作业要做,我做了。我95%肯定这是一个正确的代码。我不知道为什么,但不幸的是,我得到语法错误的一行。这是我的密码:

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((balance-(monthlyPaymentRate*balance))*(1+(annualinterestate/12)),2)。这可能是一个非常简单的问题,但我是Python的新手,无法理解到底是什么问题,我知道Python对空格和缩进非常敏感,对此我很小心。有什么建议吗?你知道吗


Tags: 代码密码作业printbalance语法错误minimumwhile

热门问题