贷款计算器
M = 0
L = raw_input("What is the loan amount you took? ")
i = raw_input("What is the interest for the loan amount? ")
k = raw_input("No of payments or years you are considering for this loan? ")
M = L[i(1+i)k] / [(1+i)k-1]
print("Your monthly payment is %f" %M)
错误:
M = L[i(1+i)k] / [(1+i)k-1]
^
SyntaxError: invalid syntax
无论您的输入是字符串还是数字,对于python中的乘法,您必须指定值之间的
*
。你知道吗如果希望输入仅为数字,则应使用
input()
,或者将raw_input()
转换为int作为int(raw_input())
为什么你没有在
是因为python认为
i(1+i)
是一个函数调用。你知道吗我想应该是这样的。尽管我很困惑,如果你想让k先减后乘:
或要递减的分母:
另外,您不需要声明M=0,因为它没有任何用处。你知道吗
相关问题 更多 >
编程相关推荐