I have asked to reduce the code to removing duplication :
june_hours = 243
june_cost = june_hours * 0.65
print("In June we spent: " + str(june_cost))
july_hours = 325
july_cost = july_hours * 0.65
print("In July we spent: " + str(july_cost))
august_hours = 298
august_cost = august_hours * 0.65
print("In August we spent: " + str(august_cost))
I tried to :
def print_monthly_expense(month, hours):
time = hours * 0.65
print("In " + month + " We spent : " + str(time))
print_monthly_expense("June",243)
print_monthly_expense("July",325)
print_monthly_expense("August",298)
And the result is :
In June We spent : 157.95000000000002
In July We spent : 211.25
In August We spent : 193.70000000000002
And the system replied :
Not quite. Let your function do most of the work and just pass the name of the month and the associated hours as parameters.
Remember for June, July and August the hours are 243, 325 and 298 respectively.
Please help me, whats wrong with the code?
thanks in advance