所以我是一个初学者,我试图做一个简单的抵押计算器。这是我的代码:
L=input('Enter desired Loan amount: ')
I=input('Enter Interest Rate: ')
N=input('Enter time length of loan in months: ')
MonthlyPayments= [float(L)*float(I)*(1+float(I))*float(N)]/((1+float(I))*float(N)-1)
print('Your Monthly Payments will be {0:.2f}'.format(MonthlyPayments))`
我得到一个错误:不支持/:“list”和“float”的操作数类型
这里:
本部分:
^{pr2}$提供“list”数据类型。将
[]
替换为()
首先使用方括号将创建一个列表,它可能不是您想要的。另外,为了避免不断转换,您可以(并且应该)用您期望的类型包装输入调用。在
从你的示例代码来看,我会这样写:
这也使它更容易阅读
“[”和“]”创建列表。在
相关问题 更多 >
编程相关推荐