我是新来的编码,我不能找出错误在我的作业
请看下面的代码和帮助
#LOAN CALCULATOR ask for help
monthlyPayment = 0
loanAmount=input('please enter the loan amount \n')
##make the returned input a numeric value
float(loanAmount)
interestRate=input('please enter the interest rate \n')
##make the returned input a numeric value
float(interestRate)
numOfpay=input('please enter the number of installments \n')
##make the returned input a numeric value
float(numOfpay)
##monthlypayment = (L*(i*(1+i)**n)/((1+i)**(n)-1))
monthlyPayment= (loanAmount*(interestRate*(1+interestRate)**numOfpay) / ((1+interestRate)**(numOfpay)-1))
print(monthlyPayment)
我希望每月分期付款,但我要这个
TypeError: unsupported operand type(s) for +: 'int' and 'str'
当您试图将一个值转换为浮点(或任何数据类型)时,必须将它重新赋给同一个变量
float(loanAmount)
应该是loanAmount = float(loanAmount)
这将确保它转换了数据类型
相关问题 更多 >
编程相关推荐