我是一名Python初學者,正在從事一項任務。即使在研究錯誤並應用建議的修復之後,我仍然收到TypeError: unsupported operand type(s) for -: 'int' and 'function'
。我不是在尋找任何人給我一個解決方案,但我會很感激第二次看。我錯過了一些東西,但我不知道是什麼。這是我遇到的麻煩的一段代碼:Python TypeError:不支持的操作數類型爲 - :'int'和'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 <module>
newbalance = ((previousbalance - minMonPay) * (monInt))
TypeError: unsupported operand type(s) for -: 'int' and 'function'
我真的很感激任何見解。謝謝。
我想我沒有牢牢掌握何時使用方法。我採納了你的建議並刪除了它們,但現在不需要任何輸入。我沒有刪除所有舊的編碼,只是現在評論它。這是我的: – KMarciszewski
@KMarciszewski增加了一件事。如果您遇到新問題,請發佈錯誤消息 –
目前我沒有收到任何錯誤。我什麼都沒有得到。這不是要求輸入或其他任何東西。 – KMarciszewski