2016-04-28 97 views
0

类型错误:“诠释”对象不是可调用蟒“int对象是不可调用的”

任何人都知道如何解决这个问题?我知道错误总是在等式中的某个地方。由于

decimal = 0 

rate = 0 

principal = 0 

years = 0 

def simple(p, r, n,): 

    decimal = r/100 
    print("Principal: " + str(p)) 
    print("Rate: " + str(decimal)) 
    print("Number of Years: " + str(n)) 

    total = p (1 + (decimal * n)) 
    print("Total: " + str(total)) 

def main(): 

    principal = int(input("Enter Principal: ")) 
    rate = float(input("Enter Rate: ")) 
    years = int(input("Enter Numbers of Years: ")) 

    simple(principal, rate, years) 

main() 

print("End of Program") 
+0

既然这是python代码缩进它将是非常有用的,因为错误的缩进可能会导致一些意想不到的问题! – SSchneid

回答

1

这里P是你试图调用一个整数:

total = p (1 + (decimal * n)) 

我想你想:

total = p*(1 + (decimal * n)) 
0

在此线P预计,因为功能紧接着是括号:

total = p (1 + (decimal * n)) 

但是p作为上面的参数传递,所以我猜你正在传递一个整数。如果你的意思是相乘:

total = p * (1 + (decimal * n))