【发布时间】:2022-01-04 01:43:54
【问题描述】:
我对我的代码感到困惑,我认为我做的一切都是正确的,但我不确定如何让我的代码的第二部分工作,即“total_costs”函数。我现在看了很多视频,但似乎找不到关于这个的,有人可以向我解释为什么我的代码的第二部分不能工作吗?
def get_input():
e1 = float(input("What is the monthly expense for House Payment. "))
e2 = float(input("What is the monthly expense for Homeowners Insurance. "))
e3 = float(input("What is the monthly expense for Car Payments. "))
e4 = float(input("What is the monthly expense for Car Insurance. "))
e5 = float(input("What is the monthly expense for Utilities. "))
print("The monthly expenses total to",format(monthly, ',.2f'))
print("The yearly expenses total to",format(yearly, ',.2f'))
def total_costs():
monthly = e1 + e2 + e3 + e4 + e5
yearly = monthly * 12
return monthly, yearly
get_input()
【问题讨论】: