【发布时间】:2019-11-17 01:23:39
【问题描述】:
如果有人可以帮我找到错误。变量名称(monthly_budgets)在函数之外未解析,并且在调用时。我是 python 的新程序员,因此将不胜感激帮助和任何提示。
def monthlbudgetoverview(monthly_expense_budget, monthly_savings_budget, monthly_spending_budget):
monthly_expense_budget = float(budget_income_five * 4)
monthly_savings_buget = float(budget_income_seven * 4)
monthly_spending_budget = float(budget_income_eight * 4)
return monthly_expense_budget, monthly_savings_budget, monthly_spending_budget
print("Your monthly bill budget is ${}" .format(monthly_expense_budget))
print("Your monthly savings budget is ${}" .format(monthly_savings_buget))
print("Your monthly spending budget is ${}" .format(monthly_spending_budget))
monthlbudgetoverview(monthly_expense_budget, monthly_spending_budget, monthly_spending_budget)
【问题讨论】:
-
您不使用
monthlbudgetoverview的返回值...您调用它并在其中有一个return但您需要 1)在打印之前进行调用 2)分配给返回对某事有价值。 -
尝试将
print语句放在monthlbudgetoverview方法中,然后再返回。
标签: python python-3.x scope