python - Python:“IndentationError:unindent 不匹配任何外部缩进级别”尝试排除故障但不起作用
问题描述
当我运行我的代码时,即使我没有看到任何错误请帮助
def savings_tracker():
input("This program will tracker your savings progress. (Press Enter to Continue)")
goal = input("What are you trying to save for?")
final_savings_amount = float(input("What is the total amount of money needed to each your goal"))
monthly_savings = float (input("What is your monthly savings?"))
current_savings = float(input("What have you saved so far?"))
month_to_reach_goal = (final_savings_amount-current_savings)/monthly_savings
month_to_reach_goal = math.ceil(month_to_reach_goal)
print("The time it will take to get to your goal of", goal, "is", month_to_reach_goal, "months!")
print("Your getting there! Keep on saving!")
解决方案
我相信这对你有用:
import math
def savings_tracker():
input("This program will tracker your savings progress. (Press Enter to Continue)")
goal = input("What are you trying to save for? ")
final_savings_amount = float(input("What is the total amount of money needed to each your goal "))
monthly_savings = float (input("What is your monthly savings ?"))
current_savings = float(input("What have you saved so far? "))
month_to_reach_goal = (final_savings_amount-current_savings)/monthly_savings
month_to_reach_goal = math.ceil(month_to_reach_goal)
print(f"The time it will take to get to your goal of {goal} is {month_to_reach_goal} months!")
print("You're getting there! Keep on saving!")
savings_tracker()
输入:
This program will tracker your savings progress. (Press Enter to Continue)
What are you trying to save for? a house
What is the total amount of money needed to each your goal 250000
What is your monthly savings? 6000
What have you saved so far? 50000
输出:
The time it will take to get to your goal of a house is 34 months!
You're getting there! Keep on saving!
推荐阅读
- c# - 如何在c#中将字母数字值转换为int
- java - 当我们使用超类引用变量创建子类对象时,内存如何分配给超类和子类成员
- php - 如果参数是数组变量,如何在codeigniter模型中调用存储过程?
- c# - C# 加载文件名中带有句号/句点的文件时出错
- css - 宽度在 IE11 中不换行
- scala - 使用 Mockito 在 Scala 对象中模拟一个函数
- qt - 单击QML中另一个SpinBox的按钮时如何使SpinBox失去焦点
- google-cloud-ml - 处理在线预测请求
- android - 使用 OTP 在 Firebase 中注册
- radio-button - 角度材料 7:无法使用键盘正确选择组件内的单选按钮