我是一个Python初学者,正在做一个作业。即使在研究了错误并应用了建议的修复方法之后,我仍然会得到TypeError: unsupported operand type(s) for -: 'int' and 'function'。我不想找任何人给我一个解决方案,但我希望再看一眼。我错过了什么,但我不知道。这是我遇到问题的代码部分:month = 0
interestYDT = 0
balance = int(raw_input ("Enter balance on credit card: "))
annualInterestRate = float(raw_input ("Enter annual interest rate as a decimal: "))
monthlyPaymentRate = float(raw_input ("Enter minimum monthly payment rate as a decimal: "))
previousbalance = balance
#
def monthlyInterestRate(annualInterestRate):
return float(annualInterestRate/12)
#
if month <= 12:
def minimumMonthlyPayment(previousbalance):
return (previousbalance * monthlyPaymentRate)
def monthlyInterest(monthlyInterestRate):
return (1 + monthlyInterestRate)
minMonPay = minimumMonthlyPayment
monInt = monthlyInterest
newbalance = ((previousbalance - minMonPay) * (monInt))
interestYDT = (interestYTD + montInt)
previousbalance = (newbalance)
print ''
print ('Month:' (month))
print ('Minimum monthly payment: $ ' (round(minimumMonthlyPayment, 2)))
print ('Remainging balance: $ ' (round(newbalance, 2)))
print ' '
month = (month + 1)
这就是我得到的全部错误:Traceback (most recent call last):
File "C:/Users/Karla/Documents/_MIT 600X Introduction to CS and Prog/Assignments/Week2/kmarciszewski_week2_Problemset_Problem1.py", line 33, in
newbalance = ((previousbalance - minMonPay) * (monInt))
TypeError: unsupported operand type(s) for -: 'int' and 'function'
我真的很感激你的洞察力。谢谢您。