0
所以我試圖編程的東西,並有一些奇怪的事情,當試圖運行我的代碼我得到的第3行語法錯誤,但是當我只運行特定的代碼行一切正常。這怎麼可能?它是用python寫的(如果有的話)代碼中的語法錯誤,但不是在代碼行
p = float(input("What is the initial investment? "))
r = float(input("What is the nominal interest rate as a decimal? ")
n = float(input("How many times a year will the interest be compounded? "))
t = float(input("How many years will the interest be compounded"))
a = p * (1 + r/n) ** (n*t)
print "The final amount after %f years is %f" %t %a
問題出在你的第二行。關閉括號。 – Selcuk 2015-04-04 20:41:16
實際的語法錯誤在第2行 – 2015-04-04 20:42:15