前提・実現したいこと
ここに質問の内容を詳しく書いてください。
結果の数字を183だけ出したいのに1から183まで出てしまいます。解決方法はありますでしょうか?
発生している問題・エラーメッセージ
Number of months: 1 Number of months: 2 Number of months: 3 : Number of months: 182 Number of months: 183
該当のソースコード
python
1 2annual_salary=float(input("Enter your annual salary:")) 3portion_saved=float(input("Enter the percent of your salary to save, as a decimal:")) 4total_cost=float(input("Enter the cost of your dream home:")) 5portion_down_payment=0.25 6 7monthly_salary=annual_salary/12 8Head_money=total_cost*portion_down_payment 9 10c=monthly_salary*portion_saved 11current_savings=0 12r=0.04 13mo=0 14while(current_savings<Head_money): 15 current_savings=current_savings+c+current_savings*r/12 16 mo=mo+1 17 18 print("Number of months:",mo)
試したこと
なすすべがありませんでした。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/15 08:08
2018/10/15 08:10