我是初學者,所以請多多包涵。我正在嘗試解決一個非常簡單的問題,但輸入和 int 命令出現一致錯誤。我試圖解決的問題如下:您有 5 萬歐元的債務。您比較不同的存款,最賺錢的存款是年復利為 6% 的存款。您應該在該存款中投資多少錢才能在 N 年內擁有 5 萬歐元?我的代碼是:FV=50000 #future value of the deposit is 50,000 eurosI=0.06 #the interest rate of the deposit is 6%N=input("number of months:")N=int(N)print(FV/(1+I)**N)print("I should invest", FV/(1+I)**N, "euros to have", FV, " euros in", N, "months with interest", I)但是內核在第三行(輸入命令)之后停止運行和執行,當我手動按 Enter 以獲取換行符時,我收到一個 ValueError 代碼,內容為:ValueError:int() 的無效文字以 10 為基數:''有人能告訴我為什么我會收到這個錯誤嗎?我在解決問題時錯在哪里?提前致謝。
添加回答
舉報
0/150
提交
取消