Question about "Check over budget" assignment in Practice Control Flow

Hi,

I am new to coding and is currently working through Python.

Today I was doing the “Practice Control Flow”, and was assigned the following task:

"You are given a monthly budget and some expenses and need to check if the sum of the expenses goes over budget!

First, store the total of all expenses into a variable called total.

Next, check if the total is greater than the budget. If it is, store True into a variable called over_budget, otherwise store False in over_budget."

I answered with the following code, which seems to do the job, but i am not getting the assigment approved. Could anyone explain to me what I am doing wrong, and what I should be doing instead?

# Monthly budget budget = 2000 # Monthly expenses food_bill = 200 electricity_bill = 100 internet_bill = 60 rent = 1500 # Calculate the total amount of expenses total = food_bill + electricity_bill + internet_bill + rent # Check if the total is greater than the budget and store the result in over_budget if total > budget: over_budget = "True" else: over_budget = "False" # Uncomment the below lines to see the results print("Total: " + str(total)) print("Is it over budget? " + str(over_budget))

Thanks in advance for your help and patience.

Please format your code so people can read it.
Use the “</>” option to do so.

1 Like

Sorry. It should be fixed now :slight_smile:

1 Like

The task is not asking you to assign the strings "True" and "False" to the over_budget variable.

It is asking you to assign the boolean True and False to the variable.

1 Like