# 列出的答案是months = 142，当我输入相同的变量时，我得到months = 128。循环变量有问题吗？

``````annual_salary = float(input('Enter your annual salary:')) #120000

portion_saved = float(input('Enter the percent of your salary to save, as a decimal:')) #.05

total_cost = float(input('Enter the cost of your dream home:')) #500000

semi_annual_raise = float(input('Enter the semi­annual raise, as a decimal: ')) #.03

portion_down_payment = .25 * total_cost
current_savings = 0
annual_return_rate = .04

portion_saved_monthly = annual_salary / 12 * portion_saved

current_savings = current_savings + portion_saved_monthly

month = 1
while current_savings < portion_down_payment:
current_savings += (current_savings * annual_return_rate / 12) + portion_saved_monthly
month += 1
if month % 6 == 0:
annual_salary += annual_salary * semi_annual_raise
portion_saved_monthly = annual_salary / 12 * portion_saved
current_savings += (current_savings * annual_return_rate / 12) + portion_saved_monthly

print('Number of months: ', month)
``````