0

I have this program that I am having trouble writing the correct code for the functions in it. It uses functions to create a monthly budget analyzation. As you can see, some of the coding is empty. I do not know where to go from here.

def DescribeProgram():
 
   print("""\
This program uses a for loop to monitor your budget.
The program will prompt you to enter your budget, and amount spent
for a certain month and calculate if your were under or over budget.
You will have the option of choosing how many months you would like to
monitor.\n""")


GetMonths():
    Months = float(input("Enter the number of months you want to analyze")
    return Months

GetMonthBudgetandSpent(month):
      Mobudget=
      MoSpent=

AnalyzeBudget(months):
    for month in range(1,months+1):
 print("\nMonth",month,":")
 print("=======")
 MoBudget,MoSpent = GetMonthBudgetandSpent(month)

def main():
 DescribeProgram()
 months = GetMonths()
 AnalyzeBudget(months)

Please help me with this layout I have

  • All function definitions start with `def`. You're missing that on your three inner functions. Also remember that indentation is critical in Python. The three lines in your `for` loop must be indented more spaces than the `for` statement. – Tim Roberts Nov 28 '22 at 22:56
  • You probably don't want `Months` to be a float, but you need to use the same kind of statement to ask the user for budget and amount spent, right? – Tim Roberts Nov 28 '22 at 22:57
  • @TimRoberts Thank you that really helps. Can you help me figure out what to write for the GetMonths and GetMonthBudgetandSpend functions? I dont know what to write for those specific functions? –  Nov 28 '22 at 23:01
  • I suspect `GetMonths` is done. For `GetMonthBudgetandSpend`, only you know where the data is supposed to come from. Is the user supposed to type it in, like he did for `GetMonths`? That's a huge hint. – Tim Roberts Nov 28 '22 at 23:03
  • @TimRoberts Yes, the user is supposed to enter the amount of months they want to budget, the budget they have for the month, and then the amount they spent that month. –  Nov 28 '22 at 23:05
  • Great. You are already entering the number of months. Do you see that? The other code will be quite similar. – Tim Roberts Nov 28 '22 at 23:16
  • @TimRoberts Yes, I am getting error code that months is not defined –  Nov 28 '22 at 23:22
  • i dont know what I should define months as –  Nov 28 '22 at 23:30

0 Answers0