I am new to Python, I am stuck with this problem.
"If your initially deposit $10000 into the account, and earns 6% interest per year, to meet your monthly expense, at the beginning each month you withdraw $500, how long the account will be depleted?
if you withdraw $10 per month, how long the account will be depleted?
how about $50? $100?
print the end balance and number of years the account will last.
Here is I've written so far:
print"This program calculate how long your account can last."
c = initial = float (raw_input ("Enter the initial in the account:"))
d = monthly_withdrawal = float (raw_input ("Enter the monthly withdrawal:"))
i = yearly_interest_rate = float (raw_input ("Enter yearly interest rate:"))
mrate = 1/1200
year = 0
shortfall = d - mrate*c
for i in range (year+1):
if shortfall <= 0:
print "The account will last forever !"
if shortfall > 0:
year = year + 1
balance = c - shortfall
print year, balance
but it does not work. can anybody help?