I have tried to function for part c of the MIT 6.0001 PSET 1, but this function always prints zero for the saving rate. What is wrong with the function I have written such that it always prints zero? I have attached a link of the PSET 1.
def house3(annual_salary):
low=0
high=10000
rate=(low+high)/2
total_cost=10**6
down_payment=0.25*total_cost
savings=0
months=0
while abs(savings-down_payment)>100:
rate=(low+high)/2
for x in range(37):
savings+=(savings*(0.04/12))+(annual_salary/12)*(rate/10000)
if months%6==0:
annual_salary+=annual_salary*0.07
months+=1
if savings<down_payment:
low=rate
elif savings>down_payment:
high=rate
print(rate)